Data Pre-Processing

The data set we chosen is from the UCI Machine Learning Repository datasets, it has collected BEijing PM2.5 data from 2010 to 2014

beijing.data <- read.csv("PRSA_data_2010.1.1-2014.12.31.csv", header = T) # load the data set
head(beijing.data)
##   No year month day hour pm2.5 DEWP TEMP PRES cbwd   Iws Is Ir
## 1  1 2010     1   1    0    NA  -21  -11 1021   NW  1.79  0  0
## 2  2 2010     1   1    1    NA  -21  -12 1020   NW  4.92  0  0
## 3  3 2010     1   1    2    NA  -21  -11 1019   NW  6.71  0  0
## 4  4 2010     1   1    3    NA  -21  -14 1019   NW  9.84  0  0
## 5  5 2010     1   1    4    NA  -20  -12 1018   NW 12.97  0  0
## 6  6 2010     1   1    5    NA  -19  -10 1017   NW 16.10  0  0
tail(beijing.data)
##          No year month day hour pm2.5 DEWP TEMP PRES cbwd    Iws Is Ir
## 43819 43819 2014    12  31   18    10  -22   -2 1033   NW 226.16  0  0
## 43820 43820 2014    12  31   19     8  -23   -2 1034   NW 231.97  0  0
## 43821 43821 2014    12  31   20    10  -22   -3 1034   NW 237.78  0  0
## 43822 43822 2014    12  31   21    10  -22   -3 1034   NW 242.70  0  0
## 43823 43823 2014    12  31   22     8  -22   -4 1034   NW 246.72  0  0
## 43824 43824 2014    12  31   23    12  -21   -3 1034   NW 249.85  0  0
sum(is.na(beijing.data))
## [1] 2067
aggr(beijing.data, prop = T, number = T)

i <- NULL
j <- 1
compare_value_j <- 1
for ( i in 2010:2014){
  data_i <- beijing.data[beijing.data$year == i,]
  if (compare_value_j < length(na.omit(data_i$pm2.5))){
    compare_value_j <- length(na.omit(data_i$pm2.5))
    j <- j + 1
  }
  print(j + 2009) # the year will least missing value 
}
## [1] 2011
## [1] 2011
## [1] 2012
## [1] 2013
## [1] 2013
beijing.data <- as_tibble(beijing.data)

In this data sets, its collection is based on hours, and from the original data set we can see that there are lots of missing value. We need to delete the missing data. In order to reduce the impact of deleting missing values on data, we select the data of the fourth year, namely 2013.

i <- NULL
for ( i in 1:length(beijing.data$No)){
  if(beijing.data$month[i] == 3){
    beijing.data$season[i] <- 1
  }
  if(beijing.data$month[i] == 4){
    beijing.data$season[i] <- 1
  }
  if(beijing.data$month[i] == 5){
    beijing.data$season[i] <- 1
  }
  if(beijing.data$month[i] == 6){
    beijing.data$season[i] <- 2
  }
  if(beijing.data$month[i] == 7){
    beijing.data$season[i] <- 2
  }
  if(beijing.data$month[i] == 8){
    beijing.data$season[i] <- 2
  }
  if(beijing.data$month[i] == 9){
    beijing.data$season[i] <- 3
  }
  if(beijing.data$month[i] == 10){
    beijing.data$season[i] <- 3
  }
  if(beijing.data$month[i] == 11){
    beijing.data$season[i] <- 3
  }
  if(beijing.data$month[i] == 12){
    beijing.data$season[i] <- 4
  }
  if(beijing.data$month[i] == 1){
    beijing.data$season[i] <- 4
  }
  if(beijing.data$month[i] == 2){
    beijing.data$season[i] <- 4
  }
}
## Warning: Unknown or uninitialised column: 'season'.
head(beijing.data)
## # A tibble: 6 x 14
##      No  year month   day  hour pm2.5  DEWP  TEMP  PRES cbwd    Iws    Is
##   <int> <int> <int> <int> <int> <int> <int> <dbl> <dbl> <fct> <dbl> <int>
## 1     1  2010     1     1     0    NA   -21   -11  1021 NW     1.79     0
## 2     2  2010     1     1     1    NA   -21   -12  1020 NW     4.92     0
## 3     3  2010     1     1     2    NA   -21   -11  1019 NW     6.71     0
## 4     4  2010     1     1     3    NA   -21   -14  1019 NW     9.84     0
## 5     5  2010     1     1     4    NA   -20   -12  1018 NW    13.0      0
## 6     6  2010     1     1     5    NA   -19   -10  1017 NW    16.1      0
## # ... with 2 more variables: Ir <int>, season <dbl>

Data cleaning

cleanbeijing <-select(beijing.data, c("year","month","day","hour","season","pm2.5","cbwd","Iws", "Is", "Ir","DEWP", "TEMP", "PRES")) %>% 
  na.omit() %>% 
  filter(year >= 2013)%>%
  unite(timebyday, c("year", "month", "day"), remove = FALSE, sep = "-")
datatable(cleanbeijing, option = list(scrollX = TRUE))
## Warning in instance$preRenderHook(instance): It seems your data is too
## big for client-side DataTables. You may consider server-side processing:
## https://rstudio.github.io/DT/server.html

PM2.5 changes by season

#calculate the PM2.5 by day
daypm<-cleanbeijing%>%
  group_by(timebyday)%>%
  summarise(mean=mean(cleanbeijing$pm2.5))%>%
  as_tibble()
#calculate the PM2.5 by year
cleanbeijing$quality <- ifelse(cleanbeijing$pm2.5 <= 50, "good", 
                                 ifelse(cleanbeijing$pm2.5 <= 100, "moderate", 
                                        ifelse(cleanbeijing$pm2.5 <= 300, "unhealthy", "posisonous")))
qualitypm <- cleanbeijing %>% 
  group_by(year, quality) %>%
  count() %>% 
  as_tibble()

ggplot(qualitypm, aes(x = factor(year) , y = n,fill = quality)) + geom_bar(stat = 'identity', position = 'dodge')+
  theme(legend.title = element_blank())

spring<-filter(cleanbeijing,cleanbeijing$season==1)
summer<-filter(cleanbeijing,cleanbeijing$season==2)
autumn<-filter(cleanbeijing,cleanbeijing$season==3)
winter<-filter(cleanbeijing,cleanbeijing$season==4)

seasonpm<- cleanbeijing %>%
  group_by(season,quality)%>%
  count()%>%
  as_tibble()

ggplot(seasonpm, aes(x = factor(season) , y = n,fill = quality)) + geom_bar(stat = 'identity', position = 'fill')+
  theme(legend.title = element_blank())

cleanbeijing <- as.data.frame(cleanbeijing)
cleanbeijing <- cleanbeijing[,-c(2,3,4)] 
head(cleanbeijing)
##   timebyday hour season pm2.5 cbwd   Iws Is Ir DEWP TEMP PRES quality
## 1  2013-1-1    0      4    35   NW  5.81  0  0  -10   -5 1018    good
## 2  2013-1-1    1      4    31   NW  9.83  0  0  -11   -7 1017    good
## 3  2013-1-1    2      4    32   NW 11.62  0  0  -11   -7 1017    good
## 4  2013-1-1    3      4    21   NW 14.75  0  0  -14  -10 1018    good
## 5  2013-1-1    4      4    16   cv  0.45  0  0  -15  -10 1018    good
## 6  2013-1-1    5      4    15   NW  3.13  0  0  -15  -12 1019    good
time <- cleanbeijing$timebyday
time <- as.Date(as.POSIXct(ymd(time), origin = "2013-01-01"))
cleanbeijing$timebyday <- time
cleanbeijing$timestamp <- as.numeric(cleanbeijing$timebyday)
head(cleanbeijing)
##    timebyday hour season pm2.5 cbwd   Iws Is Ir DEWP TEMP PRES quality
## 1 2013-01-01    0      4    35   NW  5.81  0  0  -10   -5 1018    good
## 2 2013-01-01    1      4    31   NW  9.83  0  0  -11   -7 1017    good
## 3 2013-01-01    2      4    32   NW 11.62  0  0  -11   -7 1017    good
## 4 2013-01-01    3      4    21   NW 14.75  0  0  -14  -10 1018    good
## 5 2013-01-01    4      4    16   cv  0.45  0  0  -15  -10 1018    good
## 6 2013-01-01    5      4    15   NW  3.13  0  0  -15  -12 1019    good
##   timestamp
## 1     15706
## 2     15706
## 3     15706
## 4     15706
## 5     15706
## 6     15706
tail(cleanbeijing)
##        timebyday hour season pm2.5 cbwd    Iws Is Ir DEWP TEMP PRES
## 17334 2014-12-31   18      4    10   NW 226.16  0  0  -22   -2 1033
## 17335 2014-12-31   19      4     8   NW 231.97  0  0  -23   -2 1034
## 17336 2014-12-31   20      4    10   NW 237.78  0  0  -22   -3 1034
## 17337 2014-12-31   21      4    10   NW 242.70  0  0  -22   -3 1034
## 17338 2014-12-31   22      4     8   NW 246.72  0  0  -22   -4 1034
## 17339 2014-12-31   23      4    12   NW 249.85  0  0  -21   -3 1034
##       quality timestamp
## 17334    good     16435
## 17335    good     16435
## 17336    good     16435
## 17337    good     16435
## 17338    good     16435
## 17339    good     16435
# 
# cleanbeijing <- cleanbeijing[,-c(2,3,4,5)]

Add the numericalized combined wind to the data set

for (i in 1:length(cleanbeijing$timebyday)){
  if(cleanbeijing$cbwd[i] == "NW"){
    cleanbeijing$cbwd_data[i] = 1
  }
  if(cleanbeijing$cbwd[i] == "cv"){
    cleanbeijing$cbwd_data[i] = 2
  }
  if(cleanbeijing$cbwd[i] == "NE"){
    cleanbeijing$cbwd_data[i] = 3
  }
  if(cleanbeijing$cbwd[i] == "SE"){
    cleanbeijing$cbwd_data[i] = 4
  }
}

combine the data from one day

cleanbeijing_combin <- tapplydf(cleanbeijing, c("timestamp","season", "pm2.5", "Iws", "Is", "Ir", "DEWP", "TEMP","PRES"), "timebyday", mean)

FindMode <- function(x) {
    ux <- unique(x)
    ux[which.max(tabulate(match(x, ux)))]
}
# cleanbeijing_combin$cbwd_data <- rep(1,length(cleanbeijing_combin$timebyday))


cleanbeijing_combin$cbwd_data <-  tapply(cleanbeijing$cbwd_data, cleanbeijing$timebyday, FindMode)
cleanbeijing_combin$cbwd_data <- as.numeric(cleanbeijing_combin$cbwd_data)
# cleanbeijing_combin <- cleanbeijing_combin[,-1]
# lm.cleanbeijing_combin <- lm(pm2.5~., data = cleanbeijing_combin)
# summary(lm.cleanbeijing_combin)

Add the season categorical variable into the new data set

i <- 1
for ( i in 1:length(cleanbeijing_combin$timestamp)){
    if(month(cleanbeijing_combin$timebyday)[i] == 3){
        cleanbeijing_combin$season[i] <- "Spring"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 4){
        cleanbeijing_combin$season[i] <- "Spring"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 5){
        cleanbeijing_combin$season[i] <- "Spring"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 6){
        cleanbeijing_combin$season[i] <- "Summer"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 7){
        cleanbeijing_combin$season[i] <- "Summer"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 8){
        cleanbeijing_combin$season[i] <- "Summer"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 9){
        cleanbeijing_combin$season[i] <- "Autumn"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 10){
        cleanbeijing_combin$season[i] <- "Autumn"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 11){
        cleanbeijing_combin$season[i] <- "Autumn"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 12){
        cleanbeijing_combin$season[i] <- "Winter"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 1){
        cleanbeijing_combin$season[i] <- "Winter"
    }
    if(month(cleanbeijing_combin$timebyday)[i] == 2){
        cleanbeijing_combin$season[i] <- "Winter"
    }
}
head(cleanbeijing_combin)
##    timebyday timestamp season     pm2.5       Iws Is Ir      DEWP
## 1 2013-01-01     15706 Winter  16.50000  46.64667  0  0 -20.54167
## 2 2013-01-02     15707 Winter  18.45833 233.05625  0  0 -27.45833
## 3 2013-01-03     15708 Winter  24.50000  96.39458  0  0 -24.58333
## 4 2013-01-04     15709 Winter  78.79167  12.84167  0  0 -21.08333
## 5 2013-01-05     15710 Winter  66.41667   8.88625  0  0 -21.08333
## 6 2013-01-06     15711 Winter 131.08333  10.83833  0  0 -17.58333
##         TEMP     PRES cbwd_data
## 1  -7.208333 1023.667         1
## 2 -10.500000 1039.458         1
## 3  -9.875000 1043.458         1
## 4 -10.666667 1032.792         1
## 5  -7.583333 1028.708         1
## 6  -6.708333 1027.667         1

change cbwd into categorical variable

# cleanbeijing_combin$cbwd_data <- floor(cleanbeijing_combin$cbwd_data)
for (i in 1:length(cleanbeijing_combin$timebyday)){
  if(cleanbeijing_combin$cbwd[i] == 1){
    cleanbeijing_combin$cbwd_data[i] = "NW"
  }
  if(cleanbeijing_combin$cbwd_data[i] == 2){
    cleanbeijing_combin$cbwd_data[i] = "cv"
  }
  if(cleanbeijing_combin$cbwd_data[i] == 3){
    cleanbeijing_combin$cbwd_data[i] = "NE"
  }
  if(cleanbeijing_combin$cbwd_data[i] == 4){
    cleanbeijing_combin$cbwd_data[i] = "SE"
  }
}

multiple regression model (Full Model: Model One)

lm.cleanbeijing_combin.nolog <- lm(pm2.5~timestamp + season +Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data, data = cleanbeijing_combin)
summary(lm.cleanbeijing_combin.nolog)
## 
## Call:
## lm(formula = pm2.5 ~ timestamp + season + Iws + Is + Ir + DEWP + 
##     TEMP + PRES + cbwd_data, data = cleanbeijing_combin)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -133.406  -37.184   -8.462   25.603  294.621 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.344e+03  5.414e+02   4.329 1.71e-05 ***
## timestamp    -4.383e-04  1.178e-02  -0.037 0.970337    
## seasonSpring  2.530e+01  8.012e+00   3.158 0.001654 ** 
## seasonSummer -3.362e+01  8.985e+00  -3.742 0.000197 ***
## seasonWinter  2.408e+01  9.346e+00   2.576 0.010193 *  
## Iws          -1.657e-01  6.586e-02  -2.516 0.012075 *  
## Is           -1.544e+01  6.509e+00  -2.372 0.017953 *  
## Ir           -1.493e+01  2.967e+00  -5.032 6.13e-07 ***
## DEWP          7.567e+00  5.021e-01  15.070  < 2e-16 ***
## TEMP         -1.053e+01  7.359e-01 -14.310  < 2e-16 ***
## PRES         -2.056e+00  5.292e-01  -3.885 0.000112 ***
## cbwd_dataNE  -6.115e+01  1.226e+01  -4.988 7.66e-07 ***
## cbwd_dataNW  -2.927e+01  7.431e+00  -3.939 9.00e-05 ***
## cbwd_dataSE  -1.883e+01  6.793e+00  -2.772 0.005710 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 60.41 on 716 degrees of freedom
## Multiple R-squared:  0.4676, Adjusted R-squared:  0.4579 
## F-statistic: 48.36 on 13 and 716 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.cleanbeijing_combin.nolog)

lm.cleanbeijing_combin <- lm(log(pm2.5)~timestamp + season +Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data, data = cleanbeijing_combin)
summary(lm.cleanbeijing_combin)
## 
## Call:
## lm(formula = log(pm2.5) ~ timestamp + season + Iws + Is + Ir + 
##     DEWP + TEMP + PRES + cbwd_data, data = cleanbeijing_combin)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.70416 -0.37823  0.00651  0.38239  1.87733 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.954e+01  4.931e+00   5.991 3.30e-09 ***
## timestamp    -1.875e-05  1.073e-04  -0.175 0.861378    
## seasonSpring  2.778e-01  7.298e-02   3.806 0.000153 ***
## seasonSummer -3.984e-01  8.185e-02  -4.867 1.39e-06 ***
## seasonWinter  2.358e-01  8.514e-02   2.770 0.005749 ** 
## Iws          -4.048e-03  6.000e-04  -6.747 3.11e-11 ***
## Is           -1.424e-01  5.929e-02  -2.401 0.016588 *  
## Ir           -1.298e-01  2.703e-02  -4.802 1.91e-06 ***
## DEWP          7.699e-02  4.574e-03  16.831  < 2e-16 ***
## TEMP         -1.027e-01  6.704e-03 -15.325  < 2e-16 ***
## PRES         -2.313e-02  4.820e-03  -4.798 1.95e-06 ***
## cbwd_dataNE  -6.342e-01  1.117e-01  -5.679 1.97e-08 ***
## cbwd_dataNW  -3.219e-01  6.769e-02  -4.755 2.40e-06 ***
## cbwd_dataSE  -4.865e-02  6.188e-02  -0.786 0.432075    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5503 on 716 degrees of freedom
## Multiple R-squared:  0.5643, Adjusted R-squared:  0.5564 
## F-statistic: 71.35 on 13 and 716 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.cleanbeijing_combin)

Full model with Stepwise mothed

lm.cleanbeijing_combin_step <- step(lm.cleanbeijing_combin, direction = "both")
## Start:  AIC=-858.22
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data
## 
##             Df Sum of Sq    RSS     AIC
## - timestamp  1     0.009 216.82 -860.19
## <none>                   216.81 -858.22
## - Is         1     1.746 218.56 -854.37
## - PRES       1     6.971 223.78 -837.12
## - Ir         1     6.982 223.80 -837.09
## - Iws        1    13.786 230.60 -815.22
## - cbwd_data  3    15.821 232.63 -812.81
## - season     3    22.073 238.89 -793.45
## - TEMP       1    71.119 287.93 -653.13
## - DEWP       1    85.778 302.59 -616.88
## 
## Step:  AIC=-860.19
## log(pm2.5) ~ season + Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data
## 
##             Df Sum of Sq    RSS     AIC
## <none>                   216.82 -860.19
## + timestamp  1     0.009 216.81 -858.22
## - Is         1     1.743 218.57 -856.35
## - Ir         1     6.995 223.82 -839.01
## - PRES       1     7.319 224.14 -837.96
## - Iws        1    13.860 230.68 -816.96
## - cbwd_data  3    15.853 232.68 -814.68
## - season     3    22.275 239.10 -794.80
## - TEMP       1    76.731 293.56 -641.02
## - DEWP       1    86.630 303.45 -616.81
summary(lm.cleanbeijing_combin_step)
## 
## Call:
## lm(formula = log(pm2.5) ~ season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data, data = cleanbeijing_combin)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7064 -0.3753  0.0081  0.3812  1.8815 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  29.4031187  4.8620625   6.047 2.37e-09 ***
## seasonSpring  0.2808820  0.0707893   3.968 7.98e-05 ***
## seasonSummer -0.3962147  0.0808528  -4.900 1.18e-06 ***
## seasonWinter  0.2365248  0.0849898   2.783  0.00553 ** 
## Iws          -0.0040537  0.0005988  -6.770 2.68e-11 ***
## Is           -0.1422365  0.0592454  -2.401  0.01661 *  
## Ir           -0.1298745  0.0270035  -4.810 1.84e-06 ***
## DEWP          0.0770601  0.0045529  16.925  < 2e-16 ***
## TEMP         -0.1030429  0.0064688 -15.929  < 2e-16 ***
## PRES         -0.0232851  0.0047329  -4.920 1.08e-06 ***
## cbwd_dataNE  -0.6321514  0.1109609  -5.697 1.78e-08 ***
## cbwd_dataNW  -0.3207338  0.0673207  -4.764 2.29e-06 ***
## cbwd_dataSE  -0.0473130  0.0613691  -0.771  0.44099    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5499 on 717 degrees of freedom
## Multiple R-squared:  0.5643, Adjusted R-squared:  0.557 
## F-statistic: 77.39 on 12 and 717 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.cleanbeijing_combin_step)

Interaction of the Full model

lm.cleanbeijing_combin_interaction <- lm(log(pm2.5)~(timestamp + season + Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data)^2, data = cleanbeijing_combin)
summary(lm.cleanbeijing_combin_interaction)
## 
## Call:
## lm(formula = log(pm2.5) ~ (timestamp + season + Iws + Is + Ir + 
##     DEWP + TEMP + PRES + cbwd_data)^2, data = cleanbeijing_combin)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7028 -0.2886  0.0000  0.3166  1.2007 
## 
## Coefficients: (2 not defined because of singularities)
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              -4.768e+02  4.142e+02  -1.151 0.250114    
## timestamp                 3.247e-02  2.561e-02   1.268 0.205403    
## seasonSpring             -4.317e+01  1.627e+01  -2.653 0.008175 ** 
## seasonSummer             -2.091e+01  2.108e+01  -0.992 0.321738    
## seasonWinter             -6.411e+01  1.784e+01  -3.594 0.000351 ***
## Iws                      -6.765e-01  2.225e-01  -3.040 0.002459 ** 
## Is                       -3.329e+01  7.721e+01  -0.431 0.666469    
## Ir                       -1.639e+01  1.227e+01  -1.335 0.182228    
## DEWP                     -2.200e+00  8.715e-01  -2.525 0.011812 *  
## TEMP                      3.582e-01  1.002e+00   0.357 0.720881    
## PRES                      4.822e-01  4.029e-01   1.197 0.231783    
## cbwd_dataNE              -5.212e+01  3.912e+01  -1.332 0.183297    
## cbwd_dataNW               2.861e+01  1.508e+01   1.897 0.058272 .  
## cbwd_dataSE               9.529e+00  1.442e+01   0.661 0.508959    
## timestamp:seasonSpring    1.586e-03  3.858e-04   4.112 4.43e-05 ***
## timestamp:seasonSummer    5.489e-04  4.193e-04   1.309 0.190970    
## timestamp:seasonWinter    3.346e-04  4.412e-04   0.758 0.448613    
## timestamp:Iws            -2.184e-06  3.033e-06  -0.720 0.471835    
## timestamp:Is              1.365e-03  2.601e-03   0.525 0.599837    
## timestamp:Ir              1.241e-04  3.523e-04   0.352 0.724771    
## timestamp:DEWP            1.658e-05  2.441e-05   0.679 0.497174    
## timestamp:TEMP           -6.754e-05  3.510e-05  -1.924 0.054765 .  
## timestamp:PRES           -3.234e-05  2.491e-05  -1.298 0.194768    
## timestamp:cbwd_dataNE     2.030e-03  8.294e-04   2.447 0.014663 *  
## timestamp:cbwd_dataNW     3.407e-04  3.135e-04   1.087 0.277661    
## timestamp:cbwd_dataSE     6.303e-04  3.106e-04   2.029 0.042847 *  
## seasonSpring:Iws         -4.963e-03  2.675e-03  -1.855 0.063981 .  
## seasonSummer:Iws          3.029e-03  6.004e-03   0.505 0.614036    
## seasonWinter:Iws          1.045e-03  2.278e-03   0.459 0.646581    
## seasonSpring:Is          -1.350e-01  1.188e+00  -0.114 0.909586    
## seasonSummer:Is                  NA         NA      NA       NA    
## seasonWinter:Is                  NA         NA      NA       NA    
## seasonSpring:Ir          -6.120e-02  2.021e-01  -0.303 0.762136    
## seasonSummer:Ir           2.828e-01  1.745e-01   1.620 0.105680    
## seasonWinter:Ir           1.697e+00  1.725e+00   0.984 0.325510    
## seasonSpring:DEWP        -3.947e-02  1.499e-02  -2.633 0.008669 ** 
## seasonSummer:DEWP        -5.429e-03  2.154e-02  -0.252 0.801031    
## seasonWinter:DEWP        -1.238e-02  1.676e-02  -0.739 0.460370    
## seasonSpring:TEMP         8.742e-02  2.316e-02   3.775 0.000174 ***
## seasonSummer:TEMP         1.376e-01  2.952e-02   4.660 3.83e-06 ***
## seasonWinter:TEMP         1.366e-01  2.765e-02   4.941 9.91e-07 ***
## seasonSpring:PRES         1.714e-02  1.483e-02   1.156 0.248076    
## seasonSummer:PRES         8.819e-03  1.957e-02   0.451 0.652371    
## seasonWinter:PRES         5.751e-02  1.681e-02   3.422 0.000660 ***
## seasonSpring:cbwd_dataNE -3.174e-01  4.933e-01  -0.643 0.520147    
## seasonSummer:cbwd_dataNE -2.206e-01  4.075e-01  -0.541 0.588351    
## seasonWinter:cbwd_dataNE  3.555e-01  5.348e-01   0.665 0.506409    
## seasonSpring:cbwd_dataNW -4.833e-01  2.558e-01  -1.889 0.059294 .  
## seasonSummer:cbwd_dataNW -6.087e-01  2.707e-01  -2.249 0.024862 *  
## seasonWinter:cbwd_dataNW -6.489e-01  2.520e-01  -2.575 0.010242 *  
## seasonSpring:cbwd_dataSE -2.786e-01  2.427e-01  -1.148 0.251367    
## seasonSummer:cbwd_dataSE  7.780e-02  2.137e-01   0.364 0.715908    
## seasonWinter:cbwd_dataSE -5.297e-01  2.873e-01  -1.844 0.065700 .  
## Iws:Is                   -2.076e-02  2.291e-02  -0.906 0.365042    
## Iws:Ir                    1.486e-02  6.475e-03   2.294 0.022104 *  
## Iws:DEWP                 -3.644e-04  1.759e-04  -2.071 0.038738 *  
## Iws:TEMP                  1.126e-03  2.779e-04   4.051 5.72e-05 ***
## Iws:PRES                  6.343e-04  2.078e-04   3.052 0.002364 ** 
## Iws:cbwd_dataNE           5.566e-02  2.894e-02   1.923 0.054871 .  
## Iws:cbwd_dataNW           4.862e-02  2.268e-02   2.144 0.032432 *  
## Iws:cbwd_dataSE           5.154e-02  2.269e-02   2.272 0.023432 *  
## Is:Ir                    -4.551e+00  3.956e+00  -1.150 0.250469    
## Is:DEWP                  -4.880e-02  1.698e-01  -0.287 0.773914    
## Is:TEMP                  -4.321e-02  2.793e-01  -0.155 0.877106    
## Is:PRES                   1.011e-02  7.899e-02   0.128 0.898173    
## Is:cbwd_dataNE            4.553e+00  2.867e+00   1.588 0.112803    
## Is:cbwd_dataNW            5.287e-01  6.908e-01   0.765 0.444339    
## Is:cbwd_dataSE            1.107e+00  1.068e+00   1.036 0.300563    
## Ir:DEWP                   8.027e-02  2.245e-02   3.576 0.000376 ***
## Ir:TEMP                  -8.752e-02  2.576e-02  -3.397 0.000723 ***
## Ir:PRES                   1.418e-02  1.146e-02   1.237 0.216393    
## Ir:cbwd_dataNE           -1.861e-01  2.689e-01  -0.692 0.489118    
## Ir:cbwd_dataNW           -4.906e-02  2.079e-01  -0.236 0.813486    
## Ir:cbwd_dataSE           -3.092e-02  1.859e-01  -0.166 0.867948    
## DEWP:TEMP                 9.340e-04  8.107e-04   1.152 0.249683    
## DEWP:PRES                 2.025e-03  8.203e-04   2.468 0.013831 *  
## DEWP:cbwd_dataNE         -4.843e-02  2.619e-02  -1.849 0.064909 .  
## DEWP:cbwd_dataNW         -1.530e-02  1.516e-02  -1.009 0.313290    
## DEWP:cbwd_dataSE         -1.269e-02  1.514e-02  -0.838 0.402087    
## TEMP:PRES                 5.177e-04  8.631e-04   0.600 0.548832    
## TEMP:cbwd_dataNE          7.567e-02  4.796e-02   1.578 0.115125    
## TEMP:cbwd_dataNW         -2.209e-02  1.863e-02  -1.186 0.236207    
## TEMP:cbwd_dataSE         -1.185e-02  1.849e-02  -0.641 0.521651    
## PRES:cbwd_dataNE          1.767e-02  3.660e-02   0.483 0.629461    
## PRES:cbwd_dataNW         -3.323e-02  1.419e-02  -2.342 0.019471 *  
## PRES:cbwd_dataSE         -1.924e-02  1.428e-02  -1.347 0.178335    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4738 on 646 degrees of freedom
## Multiple R-squared:  0.7086, Adjusted R-squared:  0.6712 
## F-statistic: 18.93 on 83 and 646 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.cleanbeijing_combin_interaction)
## Warning: not plotting observations with leverage one:
##   31, 78, 79, 422

## Warning: not plotting observations with leverage one:
##   31, 78, 79, 422
## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

Natural Logarithm model (Model Two)

lm.cleanbeijing_combin_natlog <- lm(log(pm2.5)~timestamp + season + Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data, data = cleanbeijing_combin)
summary(lm.cleanbeijing_combin)
## 
## Call:
## lm(formula = log(pm2.5) ~ timestamp + season + Iws + Is + Ir + 
##     DEWP + TEMP + PRES + cbwd_data, data = cleanbeijing_combin)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.70416 -0.37823  0.00651  0.38239  1.87733 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.954e+01  4.931e+00   5.991 3.30e-09 ***
## timestamp    -1.875e-05  1.073e-04  -0.175 0.861378    
## seasonSpring  2.778e-01  7.298e-02   3.806 0.000153 ***
## seasonSummer -3.984e-01  8.185e-02  -4.867 1.39e-06 ***
## seasonWinter  2.358e-01  8.514e-02   2.770 0.005749 ** 
## Iws          -4.048e-03  6.000e-04  -6.747 3.11e-11 ***
## Is           -1.424e-01  5.929e-02  -2.401 0.016588 *  
## Ir           -1.298e-01  2.703e-02  -4.802 1.91e-06 ***
## DEWP          7.699e-02  4.574e-03  16.831  < 2e-16 ***
## TEMP         -1.027e-01  6.704e-03 -15.325  < 2e-16 ***
## PRES         -2.313e-02  4.820e-03  -4.798 1.95e-06 ***
## cbwd_dataNE  -6.342e-01  1.117e-01  -5.679 1.97e-08 ***
## cbwd_dataNW  -3.219e-01  6.769e-02  -4.755 2.40e-06 ***
## cbwd_dataSE  -4.865e-02  6.188e-02  -0.786 0.432075    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5503 on 716 degrees of freedom
## Multiple R-squared:  0.5643, Adjusted R-squared:  0.5564 
## F-statistic: 71.35 on 13 and 716 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.cleanbeijing_combin_natlog)

Interaction Model of Natural Logarithm Model

lm.interaction <- lm(log(pm2.5)~(timestamp + season + Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data)^2, data = cleanbeijing_combin)
summary(lm.interaction)
## 
## Call:
## lm(formula = log(pm2.5) ~ (timestamp + season + Iws + Is + Ir + 
##     DEWP + TEMP + PRES + cbwd_data)^2, data = cleanbeijing_combin)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7028 -0.2886  0.0000  0.3166  1.2007 
## 
## Coefficients: (2 not defined because of singularities)
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              -4.768e+02  4.142e+02  -1.151 0.250114    
## timestamp                 3.247e-02  2.561e-02   1.268 0.205403    
## seasonSpring             -4.317e+01  1.627e+01  -2.653 0.008175 ** 
## seasonSummer             -2.091e+01  2.108e+01  -0.992 0.321738    
## seasonWinter             -6.411e+01  1.784e+01  -3.594 0.000351 ***
## Iws                      -6.765e-01  2.225e-01  -3.040 0.002459 ** 
## Is                       -3.329e+01  7.721e+01  -0.431 0.666469    
## Ir                       -1.639e+01  1.227e+01  -1.335 0.182228    
## DEWP                     -2.200e+00  8.715e-01  -2.525 0.011812 *  
## TEMP                      3.582e-01  1.002e+00   0.357 0.720881    
## PRES                      4.822e-01  4.029e-01   1.197 0.231783    
## cbwd_dataNE              -5.212e+01  3.912e+01  -1.332 0.183297    
## cbwd_dataNW               2.861e+01  1.508e+01   1.897 0.058272 .  
## cbwd_dataSE               9.529e+00  1.442e+01   0.661 0.508959    
## timestamp:seasonSpring    1.586e-03  3.858e-04   4.112 4.43e-05 ***
## timestamp:seasonSummer    5.489e-04  4.193e-04   1.309 0.190970    
## timestamp:seasonWinter    3.346e-04  4.412e-04   0.758 0.448613    
## timestamp:Iws            -2.184e-06  3.033e-06  -0.720 0.471835    
## timestamp:Is              1.365e-03  2.601e-03   0.525 0.599837    
## timestamp:Ir              1.241e-04  3.523e-04   0.352 0.724771    
## timestamp:DEWP            1.658e-05  2.441e-05   0.679 0.497174    
## timestamp:TEMP           -6.754e-05  3.510e-05  -1.924 0.054765 .  
## timestamp:PRES           -3.234e-05  2.491e-05  -1.298 0.194768    
## timestamp:cbwd_dataNE     2.030e-03  8.294e-04   2.447 0.014663 *  
## timestamp:cbwd_dataNW     3.407e-04  3.135e-04   1.087 0.277661    
## timestamp:cbwd_dataSE     6.303e-04  3.106e-04   2.029 0.042847 *  
## seasonSpring:Iws         -4.963e-03  2.675e-03  -1.855 0.063981 .  
## seasonSummer:Iws          3.029e-03  6.004e-03   0.505 0.614036    
## seasonWinter:Iws          1.045e-03  2.278e-03   0.459 0.646581    
## seasonSpring:Is          -1.350e-01  1.188e+00  -0.114 0.909586    
## seasonSummer:Is                  NA         NA      NA       NA    
## seasonWinter:Is                  NA         NA      NA       NA    
## seasonSpring:Ir          -6.120e-02  2.021e-01  -0.303 0.762136    
## seasonSummer:Ir           2.828e-01  1.745e-01   1.620 0.105680    
## seasonWinter:Ir           1.697e+00  1.725e+00   0.984 0.325510    
## seasonSpring:DEWP        -3.947e-02  1.499e-02  -2.633 0.008669 ** 
## seasonSummer:DEWP        -5.429e-03  2.154e-02  -0.252 0.801031    
## seasonWinter:DEWP        -1.238e-02  1.676e-02  -0.739 0.460370    
## seasonSpring:TEMP         8.742e-02  2.316e-02   3.775 0.000174 ***
## seasonSummer:TEMP         1.376e-01  2.952e-02   4.660 3.83e-06 ***
## seasonWinter:TEMP         1.366e-01  2.765e-02   4.941 9.91e-07 ***
## seasonSpring:PRES         1.714e-02  1.483e-02   1.156 0.248076    
## seasonSummer:PRES         8.819e-03  1.957e-02   0.451 0.652371    
## seasonWinter:PRES         5.751e-02  1.681e-02   3.422 0.000660 ***
## seasonSpring:cbwd_dataNE -3.174e-01  4.933e-01  -0.643 0.520147    
## seasonSummer:cbwd_dataNE -2.206e-01  4.075e-01  -0.541 0.588351    
## seasonWinter:cbwd_dataNE  3.555e-01  5.348e-01   0.665 0.506409    
## seasonSpring:cbwd_dataNW -4.833e-01  2.558e-01  -1.889 0.059294 .  
## seasonSummer:cbwd_dataNW -6.087e-01  2.707e-01  -2.249 0.024862 *  
## seasonWinter:cbwd_dataNW -6.489e-01  2.520e-01  -2.575 0.010242 *  
## seasonSpring:cbwd_dataSE -2.786e-01  2.427e-01  -1.148 0.251367    
## seasonSummer:cbwd_dataSE  7.780e-02  2.137e-01   0.364 0.715908    
## seasonWinter:cbwd_dataSE -5.297e-01  2.873e-01  -1.844 0.065700 .  
## Iws:Is                   -2.076e-02  2.291e-02  -0.906 0.365042    
## Iws:Ir                    1.486e-02  6.475e-03   2.294 0.022104 *  
## Iws:DEWP                 -3.644e-04  1.759e-04  -2.071 0.038738 *  
## Iws:TEMP                  1.126e-03  2.779e-04   4.051 5.72e-05 ***
## Iws:PRES                  6.343e-04  2.078e-04   3.052 0.002364 ** 
## Iws:cbwd_dataNE           5.566e-02  2.894e-02   1.923 0.054871 .  
## Iws:cbwd_dataNW           4.862e-02  2.268e-02   2.144 0.032432 *  
## Iws:cbwd_dataSE           5.154e-02  2.269e-02   2.272 0.023432 *  
## Is:Ir                    -4.551e+00  3.956e+00  -1.150 0.250469    
## Is:DEWP                  -4.880e-02  1.698e-01  -0.287 0.773914    
## Is:TEMP                  -4.321e-02  2.793e-01  -0.155 0.877106    
## Is:PRES                   1.011e-02  7.899e-02   0.128 0.898173    
## Is:cbwd_dataNE            4.553e+00  2.867e+00   1.588 0.112803    
## Is:cbwd_dataNW            5.287e-01  6.908e-01   0.765 0.444339    
## Is:cbwd_dataSE            1.107e+00  1.068e+00   1.036 0.300563    
## Ir:DEWP                   8.027e-02  2.245e-02   3.576 0.000376 ***
## Ir:TEMP                  -8.752e-02  2.576e-02  -3.397 0.000723 ***
## Ir:PRES                   1.418e-02  1.146e-02   1.237 0.216393    
## Ir:cbwd_dataNE           -1.861e-01  2.689e-01  -0.692 0.489118    
## Ir:cbwd_dataNW           -4.906e-02  2.079e-01  -0.236 0.813486    
## Ir:cbwd_dataSE           -3.092e-02  1.859e-01  -0.166 0.867948    
## DEWP:TEMP                 9.340e-04  8.107e-04   1.152 0.249683    
## DEWP:PRES                 2.025e-03  8.203e-04   2.468 0.013831 *  
## DEWP:cbwd_dataNE         -4.843e-02  2.619e-02  -1.849 0.064909 .  
## DEWP:cbwd_dataNW         -1.530e-02  1.516e-02  -1.009 0.313290    
## DEWP:cbwd_dataSE         -1.269e-02  1.514e-02  -0.838 0.402087    
## TEMP:PRES                 5.177e-04  8.631e-04   0.600 0.548832    
## TEMP:cbwd_dataNE          7.567e-02  4.796e-02   1.578 0.115125    
## TEMP:cbwd_dataNW         -2.209e-02  1.863e-02  -1.186 0.236207    
## TEMP:cbwd_dataSE         -1.185e-02  1.849e-02  -0.641 0.521651    
## PRES:cbwd_dataNE          1.767e-02  3.660e-02   0.483 0.629461    
## PRES:cbwd_dataNW         -3.323e-02  1.419e-02  -2.342 0.019471 *  
## PRES:cbwd_dataSE         -1.924e-02  1.428e-02  -1.347 0.178335    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4738 on 646 degrees of freedom
## Multiple R-squared:  0.7086, Adjusted R-squared:  0.6712 
## F-statistic: 18.93 on 83 and 646 DF,  p-value: < 2.2e-16
par(mfrow = c(2,2))
plot(lm.interaction)
## Warning: not plotting observations with leverage one:
##   31, 78, 79, 422

## Warning: not plotting observations with leverage one:
##   31, 78, 79, 422
## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

Stepwise Method using in the Interaction of Natural Logarithm Model

lm.interaction.step <- step(lm.interaction, direction = "both")
## Start:  AIC=-1011.82
## log(pm2.5) ~ (timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data)^2
## 
##                       Df Sum of Sq    RSS      AIC
## - Ir:cbwd_data         3    0.1343 145.15 -1017.14
## - Is:cbwd_data         3    0.5769 145.59 -1014.92
## - DEWP:cbwd_data       3    0.7956 145.81 -1013.82
## - season:Is            1    0.0029 145.02 -1013.80
## - Is:PRES              1    0.0037 145.02 -1013.80
## - Is:TEMP              1    0.0054 145.02 -1013.79
## - Is:DEWP              1    0.0185 145.04 -1013.72
## - timestamp:Ir         1    0.0279 145.05 -1013.68
## - timestamp:Is         1    0.0618 145.08 -1013.51
## - TEMP:PRES            1    0.0808 145.10 -1013.41
## - timestamp:DEWP       1    0.1036 145.12 -1013.30
## - timestamp:Iws        1    0.1163 145.13 -1013.23
## - Iws:Is               1    0.1844 145.20 -1012.89
## - season:Ir            3    1.0456 146.06 -1012.57
## - Is:Ir                1    0.2970 145.31 -1012.32
## - DEWP:TEMP            1    0.2980 145.32 -1012.32
## - Ir:PRES              1    0.3437 145.36 -1012.09
## - TEMP:cbwd_data       3    1.1638 146.18 -1011.98
## - timestamp:PRES       1    0.3782 145.40 -1011.92
## <none>                             145.02 -1011.82
## - Iws:cbwd_data        3    1.2557 146.27 -1011.52
## - PRES:cbwd_data       3    1.5069 146.53 -1010.27
## - timestamp:TEMP       1    0.8312 145.85 -1009.65
## - Iws:DEWP             1    0.9630 145.98 -1008.99
## - timestamp:cbwd_data  3    1.9467 146.96 -1008.08
## - Iws:Ir               1    1.1815 146.20 -1007.89
## - season:Iws           3    2.0171 147.03 -1007.73
## - DEWP:PRES            1    1.3677 146.38 -1006.97
## - season:DEWP          3    2.4547 147.47 -1005.56
## - season:PRES          3    2.8543 147.87 -1003.59
## - Iws:PRES             1    2.0915 147.11 -1003.36
## - season:cbwd_data     9    5.6006 150.62 -1002.16
## - Ir:TEMP              1    2.5908 147.61 -1000.89
## - Ir:DEWP              1    2.8699 147.89  -999.51
## - timestamp:season     3    4.1075 149.12  -997.43
## - Iws:TEMP             1    3.6837 148.70  -995.51
## - season:TEMP          3    9.1326 154.15  -973.23
## 
## Step:  AIC=-1017.14
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Iws + timestamp:Is + 
##     timestamp:Ir + timestamp:DEWP + timestamp:TEMP + timestamp:PRES + 
##     timestamp:cbwd_data + season:Iws + season:Is + season:Ir + 
##     season:DEWP + season:TEMP + season:PRES + season:cbwd_data + 
##     Iws:Is + Iws:Ir + Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + 
##     Is:Ir + Is:DEWP + Is:TEMP + Is:PRES + Is:cbwd_data + Ir:DEWP + 
##     Ir:TEMP + Ir:PRES + DEWP:TEMP + DEWP:PRES + DEWP:cbwd_data + 
##     TEMP:PRES + TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - Is:cbwd_data         3    0.7274 145.88 -1019.49
## - timestamp:Ir         1    0.0011 145.15 -1019.14
## - season:Is            1    0.0034 145.16 -1019.12
## - Is:PRES              1    0.0041 145.16 -1019.12
## - Is:TEMP              1    0.0048 145.16 -1019.12
## - Is:DEWP              1    0.0194 145.17 -1019.04
## - timestamp:Is         1    0.0614 145.21 -1018.83
## - TEMP:PRES            1    0.0792 145.23 -1018.74
## - timestamp:DEWP       1    0.0947 145.25 -1018.67
## - timestamp:Iws        1    0.1190 145.27 -1018.54
## - season:Ir            3    0.9641 146.12 -1018.31
## - Iws:Is               1    0.1859 145.34 -1018.21
## - Is:Ir                1    0.3061 145.46 -1017.60
## - DEWP:TEMP            1    0.3420 145.49 -1017.42
## - timestamp:PRES       1    0.3681 145.52 -1017.29
## - Ir:PRES              1    0.3685 145.52 -1017.29
## <none>                             145.15 -1017.14
## - DEWP:cbwd_data       3    1.2285 146.38 -1016.99
## - Iws:cbwd_data        3    1.2363 146.39 -1016.95
## - timestamp:TEMP       1    0.8091 145.96 -1015.08
## - PRES:cbwd_data       3    1.6974 146.85 -1014.65
## - TEMP:cbwd_data       3    1.7514 146.90 -1014.39
## - Iws:DEWP             1    0.9798 146.13 -1014.23
## - timestamp:cbwd_data  3    1.9352 147.09 -1013.47
## - season:Iws           3    2.0390 147.19 -1012.96
## + Ir:cbwd_data         3    0.1343 145.02 -1011.82
## - DEWP:PRES            1    1.4745 146.63 -1011.76
## - season:DEWP          3    2.4144 147.57 -1011.10
## - Iws:Ir               1    1.9065 147.06 -1009.62
## - season:PRES          3    2.8852 148.04 -1008.77
## - Iws:PRES             1    2.1163 147.27 -1008.58
## - season:cbwd_data     9    5.8363 150.99 -1006.37
## - Ir:TEMP              1    3.0650 148.22 -1003.89
## - timestamp:season     3    4.0777 149.23 -1002.92
## - Ir:DEWP              1    3.6909 148.84 -1000.81
## - Iws:TEMP             1    3.7177 148.87 -1000.68
## - season:TEMP          3    9.2215 154.37  -978.18
## 
## Step:  AIC=-1019.49
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Iws + timestamp:Is + 
##     timestamp:Ir + timestamp:DEWP + timestamp:TEMP + timestamp:PRES + 
##     timestamp:cbwd_data + season:Iws + season:Is + season:Ir + 
##     season:DEWP + season:TEMP + season:PRES + season:cbwd_data + 
##     Iws:Is + Iws:Ir + Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + 
##     Is:Ir + Is:DEWP + Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + 
##     Ir:PRES + DEWP:TEMP + DEWP:PRES + DEWP:cbwd_data + TEMP:PRES + 
##     TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - season:Ir            3    0.6746 146.55 -1022.13
## - timestamp:Ir         1    0.0005 145.88 -1021.49
## - DEWP:cbwd_data       3    0.8081 146.69 -1021.46
## - Is:DEWP              1    0.0605 145.94 -1021.19
## - TEMP:PRES            1    0.0728 145.95 -1021.13
## - timestamp:DEWP       1    0.0877 145.97 -1021.05
## - Is:Ir                1    0.0937 145.97 -1021.02
## - timestamp:Iws        1    0.1225 146.00 -1020.88
## - Iws:Is               1    0.1400 146.02 -1020.79
## - DEWP:TEMP            1    0.2900 146.17 -1020.04
## - timestamp:Is         1    0.3335 146.21 -1019.83
## - timestamp:PRES       1    0.3799 146.26 -1019.59
## - Ir:PRES              1    0.3863 146.27 -1019.56
## <none>                             145.88 -1019.49
## - season:Is            1    0.4646 146.34 -1019.17
## - TEMP:cbwd_data       3    1.3073 147.19 -1018.98
## - PRES:cbwd_data       3    1.3493 147.23 -1018.77
## - Iws:cbwd_data        3    1.4347 147.31 -1018.35
## - timestamp:TEMP       1    0.8028 146.68 -1017.49
## - Is:PRES              1    0.8407 146.72 -1017.30
## + Is:cbwd_data         3    0.7274 145.15 -1017.14
## - Iws:DEWP             1    1.0325 146.91 -1016.34
## - timestamp:cbwd_data  3    1.8621 147.74 -1016.23
## - season:Iws           3    1.9863 147.87 -1015.62
## - Is:TEMP              1    1.1866 147.07 -1015.58
## + Ir:cbwd_data         3    0.2848 145.59 -1014.92
## - DEWP:PRES            1    1.5139 147.39 -1013.96
## - season:DEWP          3    2.4343 148.31 -1013.41
## - Iws:Ir               1    1.9011 147.78 -1012.04
## - season:cbwd_data     9    5.3546 151.23 -1011.18
## - Iws:PRES             1    2.0972 147.98 -1011.07
## - season:PRES          3    3.1979 149.08 -1009.66
## - Ir:TEMP              1    3.1129 148.99 -1006.08
## - timestamp:season     3    4.2079 150.09 -1004.73
## - Iws:TEMP             1    3.7024 149.58 -1003.20
## - Ir:DEWP              1    3.8149 149.69 -1002.65
## - season:TEMP          3    9.2942 155.17  -980.41
## 
## Step:  AIC=-1022.13
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Iws + timestamp:Is + 
##     timestamp:Ir + timestamp:DEWP + timestamp:TEMP + timestamp:PRES + 
##     timestamp:cbwd_data + season:Iws + season:Is + season:DEWP + 
##     season:TEMP + season:PRES + season:cbwd_data + Iws:Is + Iws:Ir + 
##     Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + Is:Ir + 
##     Is:DEWP + Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + Ir:PRES + 
##     DEWP:TEMP + DEWP:PRES + DEWP:cbwd_data + TEMP:PRES + TEMP:cbwd_data + 
##     PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - DEWP:cbwd_data       3    0.7589 147.31 -1024.35
## - TEMP:PRES            1    0.0353 146.59 -1023.95
## - Is:DEWP              1    0.0609 146.62 -1023.82
## - Is:Ir                1    0.0863 146.64 -1023.70
## - timestamp:Iws        1    0.1085 146.66 -1023.58
## - timestamp:DEWP       1    0.1106 146.66 -1023.57
## - Iws:Is               1    0.1389 146.69 -1023.43
## - DEWP:TEMP            1    0.2532 146.81 -1022.86
## - timestamp:Ir         1    0.2645 146.82 -1022.81
## - timestamp:Is         1    0.3283 146.88 -1022.49
## - timestamp:PRES       1    0.3750 146.93 -1022.26
## <none>                             146.55 -1022.13
## - season:Is            1    0.4477 147.00 -1021.90
## - PRES:cbwd_data       3    1.3857 147.94 -1021.26
## - Iws:cbwd_data        3    1.4454 148.00 -1020.96
## - timestamp:TEMP       1    0.8019 147.36 -1020.14
## - Is:PRES              1    0.8183 147.37 -1020.06
## - TEMP:cbwd_data       3    1.6299 148.18 -1020.05
## + season:Ir            3    0.6746 145.88 -1019.49
## - timestamp:cbwd_data  3    1.8777 148.43 -1018.83
## - Iws:DEWP             1    1.0731 147.63 -1018.80
## - Ir:PRES              1    1.1306 147.69 -1018.52
## + Is:cbwd_data         3    0.4379 146.12 -1018.31
## - Is:TEMP              1    1.1795 147.73 -1018.27
## - season:Iws           3    2.0204 148.57 -1018.13
## + Ir:cbwd_data         3    0.0992 146.46 -1016.62
## - DEWP:PRES            1    1.7211 148.28 -1015.60
## - Iws:Ir               1    1.7611 148.31 -1015.40
## - season:cbwd_data     9    5.1388 151.69 -1014.97
## - season:DEWP          3    2.8726 149.43 -1013.95
## - Iws:PRES             1    2.1585 148.71 -1013.45
## - season:PRES          3    3.1638 149.72 -1012.53
## - Ir:TEMP              1    3.0724 149.63 -1008.98
## - timestamp:season     3    4.0318 150.59 -1008.31
## - Iws:TEMP             1    3.7455 150.30 -1005.70
## - Ir:DEWP              1    4.8872 151.44 -1000.18
## - season:TEMP          3    8.9501 155.50  -984.85
## 
## Step:  AIC=-1024.35
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Iws + timestamp:Is + 
##     timestamp:Ir + timestamp:DEWP + timestamp:TEMP + timestamp:PRES + 
##     timestamp:cbwd_data + season:Iws + season:Is + season:DEWP + 
##     season:TEMP + season:PRES + season:cbwd_data + Iws:Is + Iws:Ir + 
##     Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + Is:Ir + 
##     Is:DEWP + Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + Ir:PRES + 
##     DEWP:TEMP + DEWP:PRES + TEMP:PRES + TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - TEMP:PRES            1    0.0614 147.37 -1026.05
## - Is:DEWP              1    0.0668 147.38 -1026.02
## - timestamp:Iws        1    0.1106 147.42 -1025.81
## - Iws:Is               1    0.1370 147.45 -1025.68
## - timestamp:DEWP       1    0.1634 147.48 -1025.55
## - Is:Ir                1    0.2244 147.54 -1025.24
## - DEWP:TEMP            1    0.2808 147.59 -1024.96
## - timestamp:Is         1    0.3069 147.62 -1024.84
## - timestamp:PRES       1    0.3845 147.70 -1024.45
## <none>                             147.31 -1024.35
## - season:Is            1    0.4075 147.72 -1024.34
## - timestamp:Ir         1    0.4304 147.74 -1024.23
## - Is:PRES              1    0.6571 147.97 -1023.11
## - PRES:cbwd_data       3    1.5210 148.83 -1022.86
## + DEWP:cbwd_data       3    0.7589 146.55 -1022.13
## - timestamp:TEMP       1    0.9167 148.23 -1021.83
## - TEMP:cbwd_data       3    1.7595 149.07 -1021.69
## + season:Ir            3    0.6254 146.69 -1021.46
## - timestamp:cbwd_data  3    1.8122 149.12 -1021.43
## - Is:TEMP              1    1.1306 148.44 -1020.77
## - Iws:DEWP             1    1.1869 148.50 -1020.50
## - Ir:PRES              1    1.2867 148.60 -1020.01
## + Ir:cbwd_data         3    0.2959 147.02 -1019.82
## - season:Iws           3    2.1556 149.47 -1019.75
## - season:cbwd_data     9    4.6973 152.01 -1019.44
## + Is:cbwd_data         3    0.2051 147.11 -1019.37
## - Iws:cbwd_data        3    2.3504 149.66 -1018.80
## - Iws:Ir               1    1.6233 148.94 -1018.35
## - DEWP:PRES            1    1.6571 148.97 -1018.19
## - Iws:PRES             1    2.0754 149.39 -1016.14
## - season:DEWP          3    3.0513 150.36 -1015.39
## - season:PRES          3    3.1679 150.48 -1014.82
## - timestamp:season     3    4.0161 151.33 -1010.72
## - Ir:TEMP              1    3.2742 150.59 -1010.31
## - Iws:TEMP             1    3.8921 151.21 -1007.32
## - Ir:DEWP              1    5.0291 152.34 -1001.85
## - season:TEMP          3    8.6770 155.99  -988.57
## 
## Step:  AIC=-1026.05
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Iws + timestamp:Is + 
##     timestamp:Ir + timestamp:DEWP + timestamp:TEMP + timestamp:PRES + 
##     timestamp:cbwd_data + season:Iws + season:Is + season:DEWP + 
##     season:TEMP + season:PRES + season:cbwd_data + Iws:Is + Iws:Ir + 
##     Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + Is:Ir + 
##     Is:DEWP + Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + Ir:PRES + 
##     DEWP:TEMP + DEWP:PRES + TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - Is:DEWP              1    0.0658 147.44 -1027.72
## - timestamp:Iws        1    0.1026 147.48 -1027.54
## - Iws:Is               1    0.1359 147.51 -1027.38
## - timestamp:DEWP       1    0.1539 147.53 -1027.29
## - Is:Ir                1    0.2203 147.59 -1026.96
## - DEWP:TEMP            1    0.2397 147.61 -1026.86
## - timestamp:Is         1    0.3066 147.68 -1026.53
## - timestamp:PRES       1    0.3346 147.71 -1026.40
## - season:Is            1    0.3856 147.76 -1026.14
## - timestamp:Ir         1    0.4009 147.78 -1026.07
## <none>                             147.37 -1026.05
## - PRES:cbwd_data       3    1.4608 148.84 -1024.85
## - Is:PRES              1    0.6798 148.05 -1024.69
## + TEMP:PRES            1    0.0614 147.31 -1024.35
## + DEWP:cbwd_data       3    0.7849 146.59 -1023.95
## - timestamp:TEMP       1    0.8786 148.25 -1023.71
## - TEMP:cbwd_data       3    1.7744 149.15 -1023.31
## - timestamp:cbwd_data  3    1.8067 149.18 -1023.16
## + season:Ir            3    0.5924 146.78 -1022.99
## - Is:TEMP              1    1.1262 148.50 -1022.49
## - Iws:DEWP             1    1.2094 148.58 -1022.08
## - Ir:PRES              1    1.2401 148.61 -1021.93
## - season:Iws           3    2.1232 149.50 -1021.61
## + Ir:cbwd_data         3    0.3061 147.07 -1021.57
## - season:cbwd_data     9    4.6505 152.03 -1021.37
## + Is:cbwd_data         3    0.1961 147.18 -1021.02
## - Iws:cbwd_data        3    2.3496 149.72 -1020.50
## - Iws:Ir               1    1.6125 148.99 -1020.11
## - season:DEWP          3    2.9911 150.37 -1017.38
## - Iws:PRES             1    2.1697 149.54 -1017.38
## - season:PRES          3    3.1191 150.49 -1016.76
## - DEWP:PRES            1    2.7767 150.15 -1014.42
## - Ir:TEMP              1    3.2409 150.62 -1012.17
## - timestamp:season     3    4.1312 151.50 -1011.87
## - Iws:TEMP             1    3.9057 151.28 -1008.96
## - Ir:DEWP              1    4.9833 152.36 -1003.77
## - season:TEMP          3    8.6174 155.99  -990.57
## 
## Step:  AIC=-1027.72
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Iws + timestamp:Is + 
##     timestamp:Ir + timestamp:DEWP + timestamp:TEMP + timestamp:PRES + 
##     timestamp:cbwd_data + season:Iws + season:Is + season:DEWP + 
##     season:TEMP + season:PRES + season:cbwd_data + Iws:Is + Iws:Ir + 
##     Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + Is:Ir + 
##     Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + Ir:PRES + DEWP:TEMP + 
##     DEWP:PRES + TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - timestamp:Iws        1    0.0918 147.53 -1029.27
## - Iws:Is               1    0.1037 147.54 -1029.21
## - timestamp:DEWP       1    0.1642 147.60 -1028.91
## - Is:Ir                1    0.1989 147.64 -1028.74
## - DEWP:TEMP            1    0.2441 147.68 -1028.52
## - season:Is            1    0.3199 147.76 -1028.14
## - timestamp:PRES       1    0.3446 147.78 -1028.02
## - timestamp:Ir         1    0.4030 147.84 -1027.73
## <none>                             147.44 -1027.72
## - timestamp:Is         1    0.6167 148.06 -1026.68
## - PRES:cbwd_data       3    1.4763 148.92 -1026.45
## + Is:DEWP              1    0.0658 147.37 -1026.05
## + TEMP:PRES            1    0.0604 147.38 -1026.02
## + DEWP:cbwd_data       3    0.7907 146.65 -1025.65
## - timestamp:TEMP       1    0.9132 148.35 -1025.22
## - TEMP:cbwd_data       3    1.7911 149.23 -1024.91
## + season:Ir            3    0.5932 146.85 -1024.67
## - timestamp:cbwd_data  3    1.8439 149.28 -1024.65
## - Is:PRES              1    1.0367 148.48 -1024.61
## - Is:TEMP              1    1.1632 148.60 -1023.99
## - Iws:DEWP             1    1.2419 148.68 -1023.60
## - Ir:PRES              1    1.2458 148.69 -1023.58
## + Ir:cbwd_data         3    0.3051 147.13 -1023.24
## - season:Iws           3    2.1341 149.57 -1023.23
## - season:cbwd_data     9    4.6707 152.11 -1022.96
## + Is:cbwd_data         3    0.2428 147.20 -1022.93
## - Iws:cbwd_data        3    2.3276 149.77 -1022.29
## - Iws:Ir               1    1.6189 149.06 -1021.75
## - season:DEWP          3    2.9720 150.41 -1019.16
## - Iws:PRES             1    2.2009 149.64 -1018.91
## - season:PRES          3    3.1373 150.58 -1018.35
## - DEWP:PRES            1    2.7810 150.22 -1016.08
## - Ir:TEMP              1    3.2448 150.69 -1013.83
## - timestamp:season     3    4.1117 151.55 -1013.65
## - Iws:TEMP             1    3.9707 151.41 -1010.33
## - Ir:DEWP              1    4.9913 152.43 -1005.42
## - season:TEMP          3    8.6325 156.07  -992.19
## 
## Step:  AIC=-1029.27
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:Ir + 
##     timestamp:DEWP + timestamp:TEMP + timestamp:PRES + timestamp:cbwd_data + 
##     season:Iws + season:Is + season:DEWP + season:TEMP + season:PRES + 
##     season:cbwd_data + Iws:Is + Iws:Ir + Iws:DEWP + Iws:TEMP + 
##     Iws:PRES + Iws:cbwd_data + Is:Ir + Is:TEMP + Is:PRES + Ir:DEWP + 
##     Ir:TEMP + Ir:PRES + DEWP:TEMP + DEWP:PRES + TEMP:cbwd_data + 
##     PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - Iws:Is               1    0.1005 147.63 -1030.77
## - Is:Ir                1    0.2042 147.74 -1030.26
## - DEWP:TEMP            1    0.2253 147.76 -1030.16
## - timestamp:DEWP       1    0.2435 147.78 -1030.07
## - season:Is            1    0.3269 147.86 -1029.65
## - timestamp:PRES       1    0.3710 147.90 -1029.44
## <none>                             147.53 -1029.27
## - timestamp:Ir         1    0.4267 147.96 -1029.16
## - timestamp:Is         1    0.6093 148.14 -1028.26
## - PRES:cbwd_data       3    1.4765 149.01 -1028.00
## + timestamp:Iws        1    0.0918 147.44 -1027.72
## + Is:DEWP              1    0.0550 147.48 -1027.54
## + TEMP:PRES            1    0.0529 147.48 -1027.53
## + DEWP:cbwd_data       3    0.7915 146.74 -1027.20
## - TEMP:cbwd_data       3    1.7472 149.28 -1026.68
## - timestamp:cbwd_data  3    1.8187 149.35 -1026.33
## - timestamp:TEMP       1    1.0320 148.56 -1026.18
## - Is:PRES              1    1.0376 148.57 -1026.15
## + season:Ir            3    0.5790 146.95 -1026.14
## - Is:TEMP              1    1.1797 148.71 -1025.46
## - season:Iws           3    2.0796 149.61 -1025.05
## - Ir:PRES              1    1.2885 148.82 -1024.92
## + Ir:cbwd_data         3    0.3054 147.23 -1024.78
## + Is:cbwd_data         3    0.2324 147.30 -1024.42
## - season:cbwd_data     9    4.6980 152.23 -1024.39
## - Iws:DEWP             1    1.4267 148.96 -1024.24
## - Iws:cbwd_data        3    2.3518 149.88 -1023.73
## - Iws:Ir               1    1.6251 149.16 -1023.27
## - season:DEWP          3    2.8966 150.43 -1021.08
## - Iws:PRES             1    2.2736 149.81 -1020.11
## - season:PRES          3    3.1107 150.64 -1020.04
## - DEWP:PRES            1    2.7405 150.27 -1017.83
## - Ir:TEMP              1    3.2176 150.75 -1015.52
## - timestamp:season     3    4.1753 151.71 -1014.90
## - Iws:TEMP             1    3.8812 151.41 -1012.31
## - Ir:DEWP              1    4.9634 152.50 -1007.12
## - season:TEMP          3    8.6109 156.14  -993.86
## 
## Step:  AIC=-1030.77
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:Ir + 
##     timestamp:DEWP + timestamp:TEMP + timestamp:PRES + timestamp:cbwd_data + 
##     season:Iws + season:Is + season:DEWP + season:TEMP + season:PRES + 
##     season:cbwd_data + Iws:Ir + Iws:DEWP + Iws:TEMP + Iws:PRES + 
##     Iws:cbwd_data + Is:Ir + Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + 
##     Ir:PRES + DEWP:TEMP + DEWP:PRES + TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - DEWP:TEMP            1    0.2188 147.85 -1031.69
## - Is:Ir                1    0.2238 147.86 -1031.67
## - season:Is            1    0.2331 147.87 -1031.62
## - timestamp:DEWP       1    0.2573 147.89 -1031.50
## - timestamp:PRES       1    0.3511 147.98 -1031.04
## <none>                             147.63 -1030.77
## - timestamp:Ir         1    0.4265 148.06 -1030.67
## - PRES:cbwd_data       3    1.4653 149.10 -1029.56
## + Iws:Is               1    0.1005 147.53 -1029.27
## + timestamp:Iws        1    0.0886 147.54 -1029.21
## + TEMP:PRES            1    0.0534 147.58 -1029.04
## + Is:DEWP              1    0.0352 147.60 -1028.95
## + DEWP:cbwd_data       3    0.7700 146.86 -1028.59
## - TEMP:cbwd_data       3    1.7408 149.37 -1028.22
## - Is:PRES              1    0.9580 148.59 -1028.05
## - timestamp:cbwd_data  3    1.7857 149.42 -1028.00
## - timestamp:Is         1    0.9855 148.62 -1027.92
## - timestamp:TEMP       1    1.0224 148.66 -1027.74
## + season:Ir            3    0.5757 147.06 -1027.63
## - Is:TEMP              1    1.1207 148.75 -1027.25
## - Ir:PRES              1    1.2938 148.93 -1026.40
## - season:Iws           3    2.1203 149.75 -1026.36
## + Ir:cbwd_data         3    0.3090 147.32 -1026.30
## - season:cbwd_data     9    4.6638 152.30 -1026.07
## - Iws:DEWP             1    1.4254 149.06 -1025.76
## + Is:cbwd_data         3    0.1534 147.48 -1025.53
## - Iws:cbwd_data        3    2.3093 149.94 -1025.44
## - Iws:Ir               1    1.6357 149.27 -1024.73
## - season:DEWP          3    2.8798 150.51 -1022.67
## - season:PRES          3    3.0759 150.71 -1021.72
## - Iws:PRES             1    2.2982 149.93 -1021.50
## - DEWP:PRES            1    2.7075 150.34 -1019.51
## - Ir:TEMP              1    3.2238 150.86 -1017.00
## - timestamp:season     3    4.2095 151.84 -1016.25
## - Iws:TEMP             1    3.9168 151.55 -1013.66
## - Ir:DEWP              1    4.9768 152.61 -1008.57
## - season:TEMP          3    8.5789 156.21  -995.54
## 
## Step:  AIC=-1031.69
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:Ir + 
##     timestamp:DEWP + timestamp:TEMP + timestamp:PRES + timestamp:cbwd_data + 
##     season:Iws + season:Is + season:DEWP + season:TEMP + season:PRES + 
##     season:cbwd_data + Iws:Ir + Iws:DEWP + Iws:TEMP + Iws:PRES + 
##     Iws:cbwd_data + Is:Ir + Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + 
##     Ir:PRES + DEWP:PRES + TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - season:Is            1    0.2327 148.08 -1032.54
## - Is:Ir                1    0.2403 148.09 -1032.51
## - timestamp:DEWP       1    0.3312 148.18 -1032.06
## - timestamp:PRES       1    0.3358 148.19 -1032.04
## <none>                             147.85 -1031.69
## - timestamp:Ir         1    0.4549 148.31 -1031.45
## + DEWP:TEMP            1    0.2188 147.63 -1030.77
## + Iws:Is               1    0.0940 147.76 -1030.16
## + timestamp:Iws        1    0.0705 147.78 -1030.04
## + Is:DEWP              1    0.0302 147.82 -1029.84
## - PRES:cbwd_data       3    1.6081 149.46 -1029.79
## + TEMP:PRES            1    0.0174 147.83 -1029.78
## + DEWP:cbwd_data       3    0.7869 147.06 -1029.59
## - Is:PRES              1    0.9113 148.76 -1029.21
## - timestamp:cbwd_data  3    1.7551 149.61 -1029.08
## - timestamp:Is         1    0.9502 148.80 -1029.02
## + season:Ir            3    0.5795 147.27 -1028.56
## - timestamp:TEMP       1    1.0486 148.90 -1028.53
## - Is:TEMP              1    1.0983 148.95 -1028.29
## - TEMP:cbwd_data       3    2.0181 149.87 -1027.80
## - season:cbwd_data     9    4.5594 152.41 -1027.52
## + Ir:cbwd_data         3    0.3472 147.50 -1027.41
## - season:Iws           3    2.1738 150.03 -1027.04
## - Iws:DEWP             1    1.4658 149.32 -1026.49
## + Is:cbwd_data         3    0.1508 147.70 -1026.44
## - Iws:cbwd_data        3    2.3134 150.16 -1026.36
## - Ir:PRES              1    1.5678 149.42 -1025.99
## - Iws:Ir               1    1.6199 149.47 -1025.74
## - season:DEWP          3    2.8150 150.67 -1023.92
## - season:PRES          3    2.8653 150.72 -1023.68
## - Iws:PRES             1    2.0881 149.94 -1023.45
## - Ir:TEMP              1    3.1469 151.00 -1018.32
## - timestamp:season     3    4.3602 152.21 -1016.48
## - Iws:TEMP             1    3.7019 151.55 -1015.64
## - DEWP:PRES            1    3.7892 151.64 -1015.22
## - Ir:DEWP              1    5.0220 152.87 -1009.31
## - season:TEMP          3    8.3981 156.25  -997.36
## 
## Step:  AIC=-1032.54
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:Ir + 
##     timestamp:DEWP + timestamp:TEMP + timestamp:PRES + timestamp:cbwd_data + 
##     season:Iws + season:DEWP + season:TEMP + season:PRES + season:cbwd_data + 
##     Iws:Ir + Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + 
##     Is:Ir + Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + Ir:PRES + 
##     DEWP:PRES + TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS     AIC
## - Is:Ir                1    0.3063 148.39 -1033.0
## - timestamp:PRES       1    0.3112 148.40 -1033.0
## - timestamp:DEWP       1    0.3362 148.42 -1032.9
## <none>                             148.08 -1032.5
## - timestamp:Ir         1    0.4507 148.53 -1032.3
## + season:Is            1    0.2327 147.85 -1031.7
## + DEWP:TEMP            1    0.2185 147.87 -1031.6
## - PRES:cbwd_data       3    1.5486 149.63 -1031.0
## + timestamp:Iws        1    0.0783 148.01 -1030.9
## - timestamp:Is         1    0.7609 148.84 -1030.8
## + TEMP:PRES            1    0.0076 148.08 -1030.6
## + Is:DEWP              1    0.0053 148.08 -1030.6
## + Iws:Is               1    0.0053 148.08 -1030.6
## - Is:PRES              1    0.8483 148.93 -1030.4
## + DEWP:cbwd_data       3    0.7595 147.32 -1030.3
## - timestamp:cbwd_data  3    1.6843 149.77 -1030.3
## - timestamp:TEMP       1    0.9801 149.06 -1029.7
## + season:Ir            3    0.5689 147.51 -1029.3
## - TEMP:cbwd_data       3    1.9450 150.03 -1029.0
## + Is:cbwd_data         3    0.3664 147.72 -1028.3
## + Ir:cbwd_data         3    0.3524 147.73 -1028.3
## - season:cbwd_data     9    4.6232 152.71 -1028.1
## - Is:TEMP              1    1.3143 149.40 -1028.1
## - season:Iws           3    2.1897 150.27 -1027.8
## - Iws:DEWP             1    1.4522 149.54 -1027.4
## - Iws:cbwd_data        3    2.3051 150.39 -1027.3
## - Ir:PRES              1    1.5600 149.64 -1026.9
## - Iws:Ir               1    1.6321 149.72 -1026.5
## - season:DEWP          3    2.7679 150.85 -1025.0
## - season:PRES          3    2.7878 150.87 -1024.9
## - Iws:PRES             1    2.0869 150.17 -1024.3
## - Ir:TEMP              1    3.1549 151.24 -1019.1
## - timestamp:season     3    4.3822 152.47 -1017.2
## - Iws:TEMP             1    3.7106 151.79 -1016.5
## - DEWP:PRES            1    3.7566 151.84 -1016.3
## - Ir:DEWP              1    5.0359 153.12 -1010.1
## - season:TEMP          3    8.3929 156.48  -998.3
## 
## Step:  AIC=-1033.04
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:Ir + 
##     timestamp:DEWP + timestamp:TEMP + timestamp:PRES + timestamp:cbwd_data + 
##     season:Iws + season:DEWP + season:TEMP + season:PRES + season:cbwd_data + 
##     Iws:Ir + Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + 
##     Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + Ir:PRES + DEWP:PRES + 
##     TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - timestamp:PRES       1    0.3066 148.70 -1033.53
## - timestamp:Ir         1    0.3088 148.70 -1033.52
## - timestamp:DEWP       1    0.4016 148.79 -1033.06
## <none>                             148.39 -1033.04
## + Is:Ir                1    0.3063 148.08 -1032.54
## + season:Is            1    0.2987 148.09 -1032.51
## + DEWP:TEMP            1    0.2372 148.15 -1032.20
## + DEWP:cbwd_data       3    0.9235 147.47 -1031.59
## + timestamp:Iws        1    0.0844 148.31 -1031.45
## - timestamp:Is         1    0.7593 149.15 -1031.31
## - Is:PRES              1    0.7934 149.18 -1031.14
## + Is:DEWP              1    0.0129 148.38 -1031.10
## + Iws:Is               1    0.0057 148.38 -1031.06
## + TEMP:PRES            1    0.0045 148.39 -1031.06
## - timestamp:cbwd_data  3    1.6851 150.07 -1030.79
## - PRES:cbwd_data       3    1.6933 150.08 -1030.75
## - timestamp:TEMP       1    1.0098 149.40 -1030.08
## + season:Ir            3    0.4645 147.93 -1029.32
## + Ir:cbwd_data         3    0.3974 147.99 -1028.99
## + Is:cbwd_data         3    0.3428 148.05 -1028.72
## - TEMP:cbwd_data       3    2.1311 150.52 -1028.63
## - season:Iws           3    2.1804 150.57 -1028.39
## - Iws:DEWP             1    1.3815 149.77 -1028.27
## - season:cbwd_data     9    4.7014 153.09 -1028.27
## - Ir:PRES              1    1.4214 149.81 -1028.08
## - Iws:cbwd_data        3    2.2523 150.64 -1028.04
## - Is:TEMP              1    1.4542 149.84 -1027.92
## - Iws:Ir               1    1.8597 150.25 -1025.94
## - season:DEWP          3    2.7238 151.11 -1025.76
## - season:PRES          3    2.7625 151.15 -1025.57
## - Iws:PRES             1    2.0788 150.47 -1024.88
## - Ir:TEMP              1    2.9240 151.31 -1020.79
## - timestamp:season     3    4.4277 152.82 -1017.57
## - Iws:TEMP             1    3.6360 152.03 -1017.36
## - DEWP:PRES            1    3.7169 152.11 -1016.98
## - Ir:DEWP              1    4.8425 153.23 -1011.59
## - season:TEMP          3    8.4448 156.84  -998.63
## 
## Step:  AIC=-1033.53
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:Ir + 
##     timestamp:DEWP + timestamp:TEMP + timestamp:cbwd_data + season:Iws + 
##     season:DEWP + season:TEMP + season:PRES + season:cbwd_data + 
##     Iws:Ir + Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + 
##     Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + Ir:PRES + DEWP:PRES + 
##     TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS     AIC
## - timestamp:Ir         1    0.2947 148.99 -1034.1
## <none>                             148.70 -1033.5
## + timestamp:PRES       1    0.3066 148.39 -1033.0
## + Is:Ir                1    0.3017 148.40 -1033.0
## - timestamp:DEWP       1    0.5340 149.23 -1032.9
## + season:Is            1    0.2706 148.43 -1032.9
## + DEWP:TEMP            1    0.2218 148.47 -1032.6
## - Is:PRES              1    0.6537 149.35 -1032.3
## - timestamp:Is         1    0.6769 149.37 -1032.2
## - timestamp:cbwd_data  3    1.5159 150.21 -1032.1
## + timestamp:Iws        1    0.1078 148.59 -1032.1
## + DEWP:cbwd_data       3    0.9156 147.78 -1032.0
## - timestamp:TEMP       1    0.7197 149.42 -1032.0
## + Is:DEWP              1    0.0073 148.69 -1031.6
## + Iws:Is               1    0.0035 148.69 -1031.5
## + TEMP:PRES            1    0.0033 148.69 -1031.5
## - PRES:cbwd_data       3    1.6403 150.34 -1031.5
## + season:Ir            3    0.4693 148.23 -1029.8
## - TEMP:cbwd_data       3    2.0345 150.73 -1029.6
## + Ir:cbwd_data         3    0.3781 148.32 -1029.4
## + Is:cbwd_data         3    0.3505 148.35 -1029.2
## - Iws:DEWP             1    1.3028 150.00 -1029.2
## - Iws:cbwd_data        3    2.1504 150.85 -1029.0
## - season:Iws           3    2.1558 150.85 -1029.0
## - Is:TEMP              1    1.3557 150.05 -1028.9
## - Ir:PRES              1    1.3566 150.05 -1028.9
## - season:cbwd_data     9    4.8009 153.50 -1028.3
## - season:DEWP          3    2.6186 151.31 -1026.8
## - Iws:Ir               1    1.9217 150.62 -1026.2
## - season:PRES          3    2.9217 151.62 -1025.3
## - Iws:PRES             1    2.2052 150.90 -1024.8
## - Ir:TEMP              1    3.0671 151.76 -1020.6
## - DEWP:PRES            1    3.4790 152.18 -1018.6
## - Iws:TEMP             1    3.5798 152.28 -1018.2
## - Ir:DEWP              1    4.9649 153.66 -1011.5
## - timestamp:season     3    5.8686 154.56 -1011.3
## - season:TEMP          3    8.7915 157.49  -997.6
## 
## Step:  AIC=-1034.08
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:DEWP + 
##     timestamp:TEMP + timestamp:cbwd_data + season:Iws + season:DEWP + 
##     season:TEMP + season:PRES + season:cbwd_data + Iws:Ir + Iws:DEWP + 
##     Iws:TEMP + Iws:PRES + Iws:cbwd_data + Is:TEMP + Is:PRES + 
##     Ir:DEWP + Ir:TEMP + Ir:PRES + DEWP:PRES + TEMP:cbwd_data + 
##     PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - timestamp:DEWP       1    0.3480 149.34 -1034.38
## <none>                             148.99 -1034.08
## + timestamp:Ir         1    0.2947 148.70 -1033.53
## + timestamp:PRES       1    0.2925 148.70 -1033.52
## - timestamp:TEMP       1    0.5301 149.52 -1033.49
## + season:Is            1    0.2506 148.74 -1033.31
## + DEWP:TEMP            1    0.2410 148.75 -1033.27
## + DEWP:cbwd_data       3    1.0106 147.98 -1033.05
## + Is:Ir                1    0.1637 148.83 -1032.89
## - timestamp:cbwd_data  3    1.5067 150.50 -1032.74
## - Is:PRES              1    0.6861 149.68 -1032.73
## + timestamp:Iws        1    0.1257 148.87 -1032.70
## - timestamp:Is         1    0.7316 149.72 -1032.51
## - PRES:cbwd_data       3    1.6064 150.60 -1032.25
## + TEMP:PRES            1    0.0126 148.98 -1032.15
## + Is:DEWP              1    0.0057 148.99 -1032.11
## + Iws:Is               1    0.0035 148.99 -1032.10
## + season:Ir            3    0.7374 148.25 -1031.71
## + Ir:cbwd_data         3    0.6509 148.34 -1031.28
## - Ir:PRES              1    1.0957 150.09 -1030.73
## - TEMP:cbwd_data       3    2.0169 151.01 -1030.27
## - season:Iws           3    2.0759 151.07 -1029.98
## + Is:cbwd_data         3    0.3434 148.65 -1029.77
## - Iws:DEWP             1    1.3489 150.34 -1029.50
## - Is:TEMP              1    1.3565 150.35 -1029.47
## - season:cbwd_data     9    4.7039 153.69 -1029.39
## - Iws:cbwd_data        3    2.2022 151.19 -1029.37
## - season:DEWP          3    2.8593 151.85 -1026.21
## - Iws:PRES             1    2.2051 151.20 -1025.36
## - season:PRES          3    3.1249 152.12 -1024.93
## - Ir:TEMP              1    2.7734 151.76 -1022.62
## - Iws:Ir               1    3.5085 152.50 -1019.09
## - DEWP:PRES            1    3.5759 152.57 -1018.77
## - Iws:TEMP             1    3.6032 152.59 -1018.64
## - Ir:DEWP              1    4.6802 153.67 -1013.50
## - timestamp:season     3    5.6106 154.60 -1013.10
## - season:TEMP          3    8.9377 157.93  -997.56
## 
## Step:  AIC=-1034.38
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:TEMP + 
##     timestamp:cbwd_data + season:Iws + season:DEWP + season:TEMP + 
##     season:PRES + season:cbwd_data + Iws:Ir + Iws:DEWP + Iws:TEMP + 
##     Iws:PRES + Iws:cbwd_data + Is:TEMP + Is:PRES + Ir:DEWP + 
##     Ir:TEMP + Ir:PRES + DEWP:PRES + TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## - timestamp:TEMP       1    0.1896 149.53 -1035.45
## <none>                             149.34 -1034.38
## + timestamp:PRES       1    0.4036 148.94 -1034.36
## + timestamp:DEWP       1    0.3480 148.99 -1034.08
## + DEWP:TEMP            1    0.3179 149.02 -1033.94
## + DEWP:cbwd_data       3    1.0858 148.25 -1033.71
## + season:Is            1    0.2657 149.07 -1033.68
## + Is:Ir                1    0.2497 149.09 -1033.60
## + timestamp:Iws        1    0.2399 149.10 -1033.55
## - timestamp:cbwd_data  3    1.5052 150.84 -1033.06
## - Is:PRES              1    0.7111 150.05 -1032.91
## + timestamp:Ir         1    0.1087 149.23 -1032.91
## + TEMP:PRES            1    0.0296 149.31 -1032.52
## + Is:DEWP              1    0.0080 149.33 -1032.42
## + Iws:Is               1    0.0059 149.33 -1032.41
## - PRES:cbwd_data       3    1.6860 151.03 -1032.18
## - timestamp:Is         1    0.9052 150.25 -1031.97
## + season:Ir            3    0.6155 148.72 -1031.40
## - Ir:PRES              1    1.0332 150.37 -1031.35
## + Ir:cbwd_data         3    0.4977 148.84 -1030.82
## - season:Iws           3    2.0499 151.39 -1030.43
## - TEMP:cbwd_data       3    2.0917 151.43 -1030.23
## + Is:cbwd_data         3    0.3353 149.00 -1030.02
## - Is:TEMP              1    1.3922 150.73 -1029.61
## - Iws:DEWP             1    1.4280 150.77 -1029.43
## - Iws:cbwd_data        3    2.2737 151.61 -1029.35
## - season:cbwd_data     9    5.0944 154.43 -1027.89
## - Iws:PRES             1    2.1991 151.54 -1025.71
## - season:DEWP          3    3.4434 152.78 -1023.74
## - season:PRES          3    3.4641 152.80 -1023.64
## - Ir:TEMP              1    2.7919 152.13 -1022.86
## - Iws:Ir               1    3.3031 152.64 -1020.41
## - Iws:TEMP             1    3.5172 152.86 -1019.39
## - DEWP:PRES            1    3.7088 153.05 -1018.47
## - timestamp:season     3    5.4268 154.77 -1014.32
## - Ir:DEWP              1    4.6225 153.96 -1014.13
## - season:TEMP          3   10.2363 159.58  -991.98
## 
## Step:  AIC=-1035.45
## log(pm2.5) ~ timestamp + season + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data + timestamp:season + timestamp:Is + timestamp:cbwd_data + 
##     season:Iws + season:DEWP + season:TEMP + season:PRES + season:cbwd_data + 
##     Iws:Ir + Iws:DEWP + Iws:TEMP + Iws:PRES + Iws:cbwd_data + 
##     Is:TEMP + Is:PRES + Ir:DEWP + Ir:TEMP + Ir:PRES + DEWP:PRES + 
##     TEMP:cbwd_data + PRES:cbwd_data
## 
##                       Df Sum of Sq    RSS      AIC
## <none>                             149.53 -1035.45
## + DEWP:TEMP            1    0.2745 149.25 -1034.80
## + DEWP:cbwd_data       3    1.0868 148.44 -1034.78
## - timestamp:cbwd_data  3    1.3812 150.91 -1034.74
## + Is:Ir                1    0.2330 149.30 -1034.59
## + season:Is            1    0.2200 149.31 -1034.53
## + timestamp:Iws        1    0.2061 149.32 -1034.46
## + timestamp:TEMP       1    0.1896 149.34 -1034.38
## - Is:PRES              1    0.7128 150.24 -1033.98
## + timestamp:Ir         1    0.0926 149.44 -1033.91
## + timestamp:PRES       1    0.0328 149.50 -1033.61
## + TEMP:PRES            1    0.0125 149.52 -1033.51
## + timestamp:DEWP       1    0.0075 149.52 -1033.49
## + Iws:Is               1    0.0074 149.52 -1033.49
## + Is:DEWP              1    0.0071 149.52 -1033.49
## - PRES:cbwd_data       3    1.7259 151.25 -1033.08
## - timestamp:Is         1    0.9490 150.48 -1032.84
## - Ir:PRES              1    0.9712 150.50 -1032.73
## + season:Ir            3    0.5580 148.97 -1032.18
## + Ir:cbwd_data         3    0.4764 149.05 -1031.78
## - TEMP:cbwd_data       3    2.0588 151.59 -1031.47
## - season:Iws           3    2.1027 151.63 -1031.26
## + Is:cbwd_data         3    0.3131 149.22 -1030.98
## - Iws:DEWP             1    1.4143 150.94 -1030.58
## - Is:TEMP              1    1.4275 150.96 -1030.52
## - Iws:cbwd_data        3    2.2739 151.80 -1030.44
## - season:cbwd_data     9    5.1078 154.64 -1028.93
## - Iws:PRES             1    2.2322 151.76 -1026.64
## - season:PRES          3    3.4310 152.96 -1024.89
## - Ir:TEMP              1    2.7126 152.24 -1024.33
## - season:DEWP          3    3.7205 153.25 -1023.51
## - Iws:Ir               1    3.2293 152.76 -1021.86
## - Iws:TEMP             1    3.5959 153.12 -1020.11
## - DEWP:PRES            1    3.7371 153.27 -1019.43
## - Ir:DEWP              1    4.4988 154.03 -1015.81
## - timestamp:season     3    6.0037 155.53 -1012.72
## - season:TEMP          3   11.4127 160.94  -987.76
summary(lm.interaction.step)
## 
## Call:
## lm(formula = log(pm2.5) ~ timestamp + season + Iws + Is + Ir + 
##     DEWP + TEMP + PRES + cbwd_data + timestamp:season + timestamp:Is + 
##     timestamp:cbwd_data + season:Iws + season:DEWP + season:TEMP + 
##     season:PRES + season:cbwd_data + Iws:Ir + Iws:DEWP + Iws:TEMP + 
##     Iws:PRES + Iws:cbwd_data + Is:TEMP + Is:PRES + Ir:DEWP + 
##     Ir:TEMP + Ir:PRES + DEWP:PRES + TEMP:cbwd_data + PRES:cbwd_data, 
##     data = cleanbeijing_combin)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.72412 -0.31420  0.02447  0.32117  1.22345 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               7.049e+01  1.391e+01   5.066 5.26e-07 ***
## timestamp                -1.240e-03  2.795e-04  -4.436 1.07e-05 ***
## seasonSpring             -5.271e+01  1.321e+01  -3.989 7.37e-05 ***
## seasonSummer             -3.264e+01  1.613e+01  -2.023 0.043470 *  
## seasonWinter             -7.199e+01  1.529e+01  -4.709 3.02e-06 ***
## Iws                      -7.055e-01  2.024e-01  -3.486 0.000522 ***
## Is                        4.431e+01  2.940e+01   1.507 0.132222    
## Ir                       -9.316e+00  4.364e+00  -2.135 0.033159 *  
## DEWP                     -1.733e+00  4.555e-01  -3.804 0.000155 ***
## TEMP                     -1.956e-01  1.662e-02 -11.771  < 2e-16 ***
## PRES                     -4.284e-02  1.284e-02  -3.337 0.000894 ***
## cbwd_dataNE              -6.027e+01  3.149e+01  -1.914 0.056093 .  
## cbwd_dataNW               2.401e+01  1.377e+01   1.744 0.081689 .  
## cbwd_dataSE               4.678e-02  1.317e+01   0.004 0.997167    
## timestamp:seasonSpring    1.535e-03  3.180e-04   4.827 1.72e-06 ***
## timestamp:seasonSummer    3.935e-04  3.140e-04   1.253 0.210611    
## timestamp:seasonWinter    8.448e-04  2.856e-04   2.958 0.003208 ** 
## timestamp:Is              8.970e-04  4.353e-04   2.061 0.039727 *  
## timestamp:cbwd_dataNE     1.581e-03  8.009e-04   1.974 0.048786 *  
## timestamp:cbwd_dataNW     1.781e-04  2.791e-04   0.638 0.523570    
## timestamp:cbwd_dataSE     4.931e-04  2.911e-04   1.694 0.090751 .  
## seasonSpring:Iws         -3.537e-03  2.259e-03  -1.566 0.117887    
## seasonSummer:Iws          6.577e-03  5.467e-03   1.203 0.229397    
## seasonWinter:Iws          1.550e-04  2.121e-03   0.073 0.941780    
## seasonSpring:DEWP        -3.964e-02  1.296e-02  -3.058 0.002318 ** 
## seasonSummer:DEWP         8.588e-03  1.764e-02   0.487 0.626462    
## seasonWinter:DEWP        -2.420e-02  1.390e-02  -1.742 0.082043 .  
## seasonSpring:TEMP         9.461e-02  1.933e-02   4.894 1.24e-06 ***
## seasonSummer:TEMP         1.316e-01  2.371e-02   5.551 4.11e-08 ***
## seasonWinter:TEMP         1.437e-01  2.199e-02   6.533 1.28e-10 ***
## seasonSpring:PRES         2.704e-02  1.287e-02   2.102 0.035943 *  
## seasonSummer:PRES         2.285e-02  1.611e-02   1.419 0.156368    
## seasonWinter:PRES         5.699e-02  1.492e-02   3.821 0.000145 ***
## seasonSpring:cbwd_dataNE  4.922e-02  4.545e-01   0.108 0.913794    
## seasonSummer:cbwd_dataNE -6.718e-02  3.887e-01  -0.173 0.862844    
## seasonWinter:cbwd_dataNE  2.502e-01  5.010e-01   0.499 0.617750    
## seasonSpring:cbwd_dataNW -3.637e-01  2.092e-01  -1.738 0.082596 .  
## seasonSummer:cbwd_dataNW -5.516e-01  2.545e-01  -2.167 0.030562 *  
## seasonWinter:cbwd_dataNW -5.796e-01  2.280e-01  -2.542 0.011258 *  
## seasonSpring:cbwd_dataSE -1.304e-01  1.956e-01  -0.667 0.505258    
## seasonSummer:cbwd_dataSE  8.702e-02  2.089e-01   0.417 0.677116    
## seasonWinter:cbwd_dataSE -3.490e-01  2.582e-01  -1.351 0.177031    
## Iws:Ir                    1.584e-02  4.168e-03   3.801 0.000157 ***
## Iws:DEWP                 -4.239e-04  1.685e-04  -2.515 0.012121 *  
## Iws:TEMP                  1.063e-03  2.649e-04   4.011 6.73e-05 ***
## Iws:PRES                  6.223e-04  1.969e-04   3.160 0.001648 ** 
## Iws:cbwd_dataNE           8.018e-02  2.614e-02   3.067 0.002248 ** 
## Iws:cbwd_dataNW           5.388e-02  2.196e-02   2.454 0.014384 *  
## Iws:cbwd_dataSE           5.666e-02  2.194e-02   2.583 0.010005 *  
## Is:TEMP                  -1.313e-01  5.197e-02  -2.527 0.011728 *  
## Is:PRES                  -5.770e-02  3.231e-02  -1.786 0.074584 .  
## Ir:DEWP                   8.322e-02  1.855e-02   4.486 8.53e-06 ***
## Ir:TEMP                  -7.109e-02  2.041e-02  -3.484 0.000527 ***
## Ir:PRES                   8.837e-03  4.239e-03   2.085 0.037489 *  
## DEWP:PRES                 1.825e-03  4.464e-04   4.089 4.86e-05 ***
## TEMP:cbwd_dataNE          3.199e-02  2.565e-02   1.248 0.212628    
## TEMP:cbwd_dataNW         -3.219e-02  1.443e-02  -2.230 0.026081 *  
## TEMP:cbwd_dataSE         -1.102e-02  1.473e-02  -0.748 0.454621    
## PRES:cbwd_dataNE          3.294e-02  2.789e-02   1.181 0.237939    
## PRES:cbwd_dataNW         -2.613e-02  1.311e-02  -1.993 0.046705 *  
## PRES:cbwd_dataSE         -7.895e-03  1.304e-02  -0.605 0.545245    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4728 on 669 degrees of freedom
## Multiple R-squared:  0.6995, Adjusted R-squared:  0.6726 
## F-statistic: 25.96 on 60 and 669 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.interaction.step)

Spring Data Re Do

Spring_data<-filter(cleanbeijing_combin,cleanbeijing_combin$season=="Spring")
names(Spring_data)
##  [1] "timebyday" "timestamp" "season"    "pm2.5"     "Iws"      
##  [6] "Is"        "Ir"        "DEWP"      "TEMP"      "PRES"     
## [11] "cbwd_data"
lm.spring.data <- lm(log(pm2.5)~timestamp + Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data, data = Spring_data)
summary(lm.spring.data)
## 
## Call:
## lm(formula = log(pm2.5) ~ timestamp + Iws + Is + Ir + DEWP + 
##     TEMP + PRES + cbwd_data, data = Spring_data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.50541 -0.33338  0.03751  0.28487  1.07201 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 17.8820167  7.0027350   2.554 0.011525 *  
## timestamp    0.0004757  0.0002151   2.211 0.028323 *  
## Iws         -0.0052019  0.0012767  -4.075 7.01e-05 ***
## Is          -0.5863416  0.2478752  -2.365 0.019114 *  
## Ir          -0.2652791  0.0567957  -4.671 6.00e-06 ***
## DEWP         0.0722984  0.0065879  10.974  < 2e-16 ***
## TEMP        -0.0926104  0.0096466  -9.600  < 2e-16 ***
## PRES        -0.0192508  0.0070238  -2.741 0.006773 ** 
## cbwd_dataNE -0.7884169  0.2328785  -3.386 0.000879 ***
## cbwd_dataNW -0.2354736  0.1495430  -1.575 0.117171    
## cbwd_dataSE -0.0815685  0.1308364  -0.623 0.533817    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4626 on 173 degrees of freedom
## Multiple R-squared:  0.6347, Adjusted R-squared:  0.6136 
## F-statistic: 30.06 on 10 and 173 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.spring.data)

winter Data Re Do

winter_data<-filter(cleanbeijing_combin,cleanbeijing_combin$season=="Winter")
names(winter_data)
##  [1] "timebyday" "timestamp" "season"    "pm2.5"     "Iws"      
##  [6] "Is"        "Ir"        "DEWP"      "TEMP"      "PRES"     
## [11] "cbwd_data"
lm.winter.data <- lm(pm2.5~timestamp + Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data, data = winter_data)
summary(lm.winter.data)
## 
## Call:
## lm(formula = pm2.5 ~ timestamp + Iws + Is + Ir + DEWP + TEMP + 
##     PRES + cbwd_data, data = winter_data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -166.376  -49.833   -9.282   40.979  278.782 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1931.58633 1340.48803   1.441  0.15145    
## timestamp     -0.03163    0.02866  -1.104  0.27125    
## Iws           -0.09560    0.11968  -0.799  0.42552    
## Is           -19.55257    8.57032  -2.281  0.02377 *  
## Ir           -57.53794  114.71867  -0.502  0.61663    
## DEWP          13.23715    1.24761  10.610  < 2e-16 ***
## TEMP          -6.32787    2.35979  -2.682  0.00806 ** 
## PRES          -1.04968    1.33372  -0.787  0.43236    
## cbwd_dataNE  -83.50435   32.18081  -2.595  0.01029 *  
## cbwd_dataNW  -36.49591   16.71471  -2.183  0.03038 *  
## cbwd_dataSE  -42.89999   18.29874  -2.344  0.02022 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 75.38 on 169 degrees of freedom
## Multiple R-squared:  0.5763, Adjusted R-squared:  0.5512 
## F-statistic: 22.98 on 10 and 169 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.winter.data)

winter_data<-filter(cleanbeijing_combin,cleanbeijing_combin$season=="Winter")
names(winter_data)
##  [1] "timebyday" "timestamp" "season"    "pm2.5"     "Iws"      
##  [6] "Is"        "Ir"        "DEWP"      "TEMP"      "PRES"     
## [11] "cbwd_data"
lm.winter.data.in <- lm(log(pm2.5)~(timestamp + Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data)^2, data = winter_data)
summary(lm.winter.data.in)
## 
## Call:
## lm(formula = log(pm2.5) ~ (timestamp + Iws + Is + Ir + DEWP + 
##     TEMP + PRES + cbwd_data)^2, data = winter_data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.14176 -0.30674 -0.00553  0.32856  1.25923 
## 
## Coefficients: (9 not defined because of singularities)
##                         Estimate Std. Error t value Pr(>|t|)  
## (Intercept)           -8.174e+02  9.364e+02  -0.873   0.3843  
## timestamp              5.037e-02  5.798e-02   0.869   0.3865  
## Iws                   -3.664e-01  4.790e-01  -0.765   0.4455  
## Is                    -7.622e-01  9.904e+01  -0.008   0.9939  
## Ir                    -1.168e+01  1.042e+02  -0.112   0.9110  
## DEWP                  -1.832e+00  2.549e+00  -0.718   0.4737  
## TEMP                   4.759e+00  3.129e+00   1.521   0.1306  
## PRES                   8.110e-01  9.154e-01   0.886   0.3772  
## cbwd_dataNE            2.926e+01  1.402e+02   0.209   0.8350  
## cbwd_dataNW            3.080e+01  3.120e+01   0.987   0.3253  
## cbwd_dataSE            1.380e+00  3.545e+01   0.039   0.9690  
## timestamp:Iws          2.048e-06  5.008e-06   0.409   0.6832  
## timestamp:Is          -1.717e-03  3.714e-03  -0.462   0.6447  
## timestamp:Ir           7.199e-04  6.588e-03   0.109   0.9131  
## timestamp:DEWP         5.347e-05  5.976e-05   0.895   0.3725  
## timestamp:TEMP        -1.503e-04  9.404e-05  -1.598   0.1123  
## timestamp:PRES        -4.959e-05  5.667e-05  -0.875   0.3831  
## timestamp:cbwd_dataNE  1.005e-04  2.875e-03   0.035   0.9722  
## timestamp:cbwd_dataNW  9.143e-04  6.335e-04   1.443   0.1512  
## timestamp:cbwd_dataSE  1.762e-03  8.840e-04   1.994   0.0482 *
## Iws:Is                -1.223e-03  3.202e-02  -0.038   0.9696  
## Iws:Ir                        NA         NA      NA       NA  
## Iws:DEWP              -6.721e-04  4.743e-04  -1.417   0.1588  
## Iws:TEMP               6.576e-04  5.491e-04   1.198   0.2331  
## Iws:PRES               2.882e-04  4.663e-04   0.618   0.5375  
## Iws:cbwd_dataNE       -9.305e-02  1.359e-01  -0.685   0.4946  
## Iws:cbwd_dataNW        2.013e-02  5.820e-02   0.346   0.7300  
## Iws:cbwd_dataSE        9.131e-03  6.026e-02   0.152   0.8798  
## Is:Ir                         NA         NA      NA       NA  
## Is:DEWP               -2.135e-01  2.199e-01  -0.971   0.3334  
## Is:TEMP                1.699e-01  3.660e-01   0.464   0.6432  
## Is:PRES                2.510e-02  1.015e-01   0.247   0.8050  
## Is:cbwd_dataNE                NA         NA      NA       NA  
## Is:cbwd_dataNW         4.357e-01  8.371e-01   0.521   0.6036  
## Is:cbwd_dataSE         1.645e+00  1.357e+00   1.212   0.2277  
## Ir:DEWP                       NA         NA      NA       NA  
## Ir:TEMP                       NA         NA      NA       NA  
## Ir:PRES                       NA         NA      NA       NA  
## Ir:cbwd_dataNE                NA         NA      NA       NA  
## Ir:cbwd_dataNW                NA         NA      NA       NA  
## Ir:cbwd_dataSE                NA         NA      NA       NA  
## DEWP:TEMP              1.127e-03  4.322e-03   0.261   0.7947  
## DEWP:PRES              1.061e-03  2.482e-03   0.427   0.6698  
## DEWP:cbwd_dataNE      -2.841e-01  2.617e-01  -1.085   0.2797  
## DEWP:cbwd_dataNW       2.425e-02  3.011e-02   0.805   0.4220  
## DEWP:cbwd_dataSE      -2.289e-03  3.363e-02  -0.068   0.9458  
## TEMP:PRES             -2.347e-03  2.704e-03  -0.868   0.3870  
## TEMP:cbwd_dataNE       3.802e-01  2.208e-01   1.722   0.0874 .
## TEMP:cbwd_dataNW      -1.687e-02  5.382e-02  -0.313   0.7545  
## TEMP:cbwd_dataSE      -6.455e-02  6.947e-02  -0.929   0.3544  
## PRES:cbwd_dataNE      -3.275e-02  1.328e-01  -0.247   0.8056  
## PRES:cbwd_dataNW      -4.434e-02  2.932e-02  -1.512   0.1328  
## PRES:cbwd_dataSE      -2.914e-02  3.422e-02  -0.852   0.3960  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5464 on 136 degrees of freedom
## Multiple R-squared:  0.7661, Adjusted R-squared:  0.6922 
## F-statistic: 10.36 on 43 and 136 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.winter.data.in)
## Warning: not plotting observations with leverage one:
##   31, 147

## Warning: not plotting observations with leverage one:
##   31, 147
## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

anova(lm.winter.data, lm.winter.data.in)
## Warning in anova.lmlist(object, ...): models with response '"log(pm2.5)"'
## removed because response differs from model 1
## Analysis of Variance Table
## 
## Response: pm2.5
##            Df Sum Sq Mean Sq  F value    Pr(>F)    
## timestamp   1 107809  107809  18.9711 2.295e-05 ***
## Iws         1 231115  231115  40.6693 1.660e-09 ***
## Is          1   1327    1327   0.2335  0.629591    
## Ir          1  15842   15842   2.7878  0.096835 .  
## DEWP        1 832581  832581 146.5095 < 2.2e-16 ***
## TEMP        1  52940   52940   9.3158  0.002639 ** 
## PRES        1  11441   11441   2.0132  0.157774    
## cbwd_data   3  53025   17675   3.1103  0.027876 *  
## Residuals 169 960389    5683                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Spring + Winter

spring_winter <- as.data.frame(rbind(Spring_data, winter_data))
names(spring_winter)
##  [1] "timebyday" "timestamp" "season"    "pm2.5"     "Iws"      
##  [6] "Is"        "Ir"        "DEWP"      "TEMP"      "PRES"     
## [11] "cbwd_data"
for (i in 1:length(spring_winter$timebyday)){
  if(spring_winter$season == 1){
    spring_winter$season[i] = "Spring"
  }
  if(spring_winter$season == 4){
      spring_winter$season[i] = "Winter"
    }
}
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 1) {: the condition has length > 1
## and only the first element will be used
## Warning in if (spring_winter$season == 4) {: the condition has length > 1
## and only the first element will be used
lm.plus.data <- lm(log(pm2.5)~timestamp + Iws + Is + Ir + DEWP + TEMP + PRES + cbwd_data + season, data = spring_winter)
summary(lm.plus.data)
## 
## Call:
## lm(formula = log(pm2.5) ~ timestamp + Iws + Is + Ir + DEWP + 
##     TEMP + PRES + cbwd_data + season, data = spring_winter)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.49516 -0.35579  0.01672  0.37853  1.29634 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.276e+01  6.034e+00   3.771  0.00019 ***
## timestamp     9.375e-05  1.507e-04   0.622  0.53434    
## Iws          -5.644e-03  7.039e-04  -8.017 1.61e-14 ***
## Is           -1.212e-01  5.750e-02  -2.108  0.03570 *  
## Ir           -2.770e-01  6.195e-02  -4.471 1.05e-05 ***
## DEWP          8.261e-02  5.566e-03  14.842  < 2e-16 ***
## TEMP         -8.693e-02  8.633e-03 -10.070  < 2e-16 ***
## PRES         -1.800e-02  6.020e-03  -2.990  0.00299 ** 
## cbwd_dataNE  -7.436e-01  1.700e-01  -4.373 1.61e-05 ***
## cbwd_dataNW  -3.206e-01  9.567e-02  -3.352  0.00089 ***
## cbwd_dataSE  -2.150e-01  9.384e-02  -2.291  0.02257 *  
## seasonWinter  1.460e-01  1.066e-01   1.369  0.17190    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5292 on 352 degrees of freedom
## Multiple R-squared:  0.6456, Adjusted R-squared:  0.6345 
## F-statistic: 58.29 on 11 and 352 DF,  p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(lm.plus.data)

library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:purrr':
## 
##     some
qqPlot(lm.winter.data, labels = row.names(winter_data), id.methods = "identify", simulate = T, main = "Q-Q plot")

## [1]  12 106
residplot <- function(fit, nbreaks = 10){
  z <- rstudent(fit)
  hist(z, breaks = nbreaks, freq = FALSE,
       xlib = "Studentized Residual",
       main = "Distribution of Errors")
  rug(jitter(z), col = "brown")
  curve(dnorm(x), mean = mean(z), sd = sd(z), add = TRUE, col = "blue",lwd = 2)
lines(density(z)$x, density(z)$y,
      col="red", lwd = 2, lty = 2)
legend("topright", 
       legend = c("Normal Curve", "Kernel Density Curve"),
       lty = 1:2, col = c("blue", "red"), cex=.7)
}
residplot(lm.winter.data)
## Warning in plot.window(xlim, ylim, "", ...): "xlib" is not a graphical
## parameter
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "xlib" is not a graphical parameter
## Warning in axis(1, ...): "xlib" is not a graphical parameter
## Warning in axis(2, ...): "xlib" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "mean" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "sd" is not a
## graphical parameter

library(car)
ncvTest(lm.winter.data)
## Non-constant Variance Score Test 
## Variance formula: ~ fitted.values 
## Chisquare = 44.15907, Df = 1, p = 3.0275e-11
spreadLevelPlot(lm.winter.data)
## Warning in spreadLevelPlot.lm(lm.winter.data): 
## 12 negative fitted values removed

## 
## Suggested power transformation:  0.2079793